WPF:多个控件更改绑定属性 [英] WPF: change binding properties for multiple controls
问题描述
我想,所有的文本
绑定的文本框
ES在我的用户控件
有 UpdateSourceTrigger =的PropertyChanged
和 ValidatesOnDataErrors = TRUE
I'd like that all the Text
bindings for the TextBox
es in my UserControl
to have UpdateSourceTrigger=PropertyChanged
, and ValidatesOnDataErrors=True
怎么办呢?
我想到了解决办法:使用另一个类的绑定(一个类继承绑定
),但也许有另一种解决方案,也许使用样式或模板
I can think of a solution: use another class for bindings (a class inheriting Binding
) but maybe there is another solution, maybe using a style or template ?
推荐答案
您不能样式或模板做到这一点,因为绑定是不是 FrameworkElement的
。但是,你的一个类继承的想法绑定
应该可以正常工作,我已经做了相同的前一个类似的问题
You can't do it with a style or template, since a binding is not a FrameworkElement
. But your idea of a class inheriting Binding
should work fine, I've done the same before for a similar problem
这篇关于WPF:多个控件更改绑定属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!