WPF 控件的 Binding.Mode=Default 的默认值是什么? [英] What are the defaults for Binding.Mode=Default for WPF controls?

查看:26
本文介绍了WPF 控件的 Binding.Mode=Default 的默认值是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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, have TwoWay as their default Mode value. To figure out if the default is TwoWay, look at the Dependency Property Information section of the property. If it says BindsTwoWayByDefault is set to true, then the default Mode value of the property is TwoWay. To do it programmatically, get the property metadata of the property by calling GetMetadata and then check the boolean value of the BindsTwoWayByDefault property.

来源:https://web.archive.org/web/20100209025938/http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx

最安全的方法是始终明确您希望从绑定中获得哪种绑定模式.

The safest way would be to always be explicit what kind of binding mode you want from a binding.

这篇关于WPF 控件的 Binding.Mode=Default 的默认值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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