如何在WPF中获取控件属性的默认绑定模式?

Wpf*_*Bee 1 wpf

我知道如果控件的属性是用户可编辑的,那么它将支持双向绑定模式.例如,TextBox.Text属性也可以获取和设置.

所以,我的问题是[以编程方式/设计器属性窗口查看]如何获得控件属性的默认模式.即对于TextBox.Text,默认绑定模式本身就是双向的,而不是单向,单向源或一次.

我希望,我很清楚我的问题.如果不清楚,请问我.

Nic*_*ick 5

TextBox text = new TextBox();

...

// Set your binding
...

// Get the binding
Binding binding = BindingOperations.GetBinding(text, TextBox.TextProperty);

if (binding != null)
{
   // Get the mode
   BindingMode mode = binding.Mode;
}
Run Code Online (Sandbox Code Playgroud)