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
作为其默认Mode值。若要确定
(如果默认值为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屋!