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

查看:309
本文介绍了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
作为其默认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, 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天全站免登陆