WPF:多个控件更改绑定属性 [英] WPF: change binding properties for multiple controls

查看:333
本文介绍了WPF:多个控件更改绑定属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,所有的文本绑定的文本框 ES在我的用户控件 UpdateSourceTrigger =的PropertyChanged ValidatesOnDataErrors = TRUE

I'd like that all the Text bindings for the TextBoxes 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆