WPF 控件的 Binding.Mode=Default 的默认值是什么? [英] What are the defaults for Binding.Mode=Default for WPF controls?
问题描述
在 WPF Binding.Mode
,选择默认,取决于被绑定的属性.
In WPF Binding.Mode
, when selecting Default, it depends in the property being binded.
我正在寻找一些列表或一些约定或各种控件默认值的任何信息.
我的意思是,什么属性是 TwoWay
默认情况下等等.欢迎任何链接、想法、想法甚至咆哮!
I am looking for some list or some convention or any information for the defaults for the various controls.
I mean, what properties are TwoWay
by default and so on.
Any links, ideas, thoughts and even rants are welcommed!
推荐答案
类似于 UpdateSourceTrigger,Mode 属性的默认值每个属性不同.用户可编辑的属性,例如
TextBox.Text
,ComboBox.Text
,MenuItem.IsChecked
等,有TwoWay
作为他们的默认模式值.要图如果默认为TwoWay
,请查看依赖属性信息财产的一部分.如果它说BindsTwoWayByDefault
设置为 true,然后是默认的 Mode 值属性是TwoWay
.去做吧以编程方式,获取属性通过调用属性的元数据GetMetadata
然后检查布尔值BindsTwoWayByDefault
的值财产.
Similar to UpdateSourceTrigger, the default value for the Mode property varies for each property. User-editable properties such as
TextBox.Text
,ComboBox.Text
,MenuItem.IsChecked
, etc, haveTwoWay
as their default Mode value. To figure out if the default isTwoWay
, look at the Dependency Property Information section of the property. If it saysBindsTwoWayByDefault
is set to true, then the default Mode value of the property isTwoWay
. To do it programmatically, get the property metadata of the property by callingGetMetadata
and then check the boolean value of theBindsTwoWayByDefault
property.
最安全的方法是始终明确您希望从绑定中获得哪种绑定模式.
The safest way would be to always be explicit what kind of binding mode you want from a binding.
这篇关于WPF 控件的 Binding.Mode=Default 的默认值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!