Binding.Mode 属性

定义

获取或设置一个值,该值指示绑定的数据流方向。Gets or sets a value that indicates the direction of the data flow in the binding.

public:
 property System::Windows::Data::BindingMode Mode { System::Windows::Data::BindingMode get(); void set(System::Windows::Data::BindingMode value); };
public System.Windows.Data.BindingMode Mode { get; set; }
member this.Mode : System.Windows.Data.BindingMode with get, set
Public Property Mode As BindingMode

属性值

BindingMode

BindingMode 值之一。One of the BindingMode values. 默认值为 Default,它返回目标依赖属性的默认绑定模式值。The default is Default, which returns the default binding mode value of the target dependency property. 但是,每个依赖属性的默认值都不同。However, the default value varies for each dependency property. 通常,用户可编辑的控件属性(如文本框和复选框的控件属性)默认为双向绑定,而其他大多数属性默认为单向绑定。In general, user-editable control properties, such as those of text boxes and check boxes, default to two-way bindings, whereas most other properties default to one-way bindings.

确定依赖属性绑定在默认情况下是单向还是双向的编程方法是:使用 GetMetadata(Type) 获取属性的属性元数据,然后检查 BindsTwoWayByDefault 属性的布尔值。A programmatic way to determine whether a dependency property binds one-way or two-way by default is to get the property metadata of the property using GetMetadata(Type) and then check the Boolean value of the BindsTwoWayByDefault property.

注解

若要支持 OneWayTwoWay 绑定,基础数据必须实现 INotifyPropertyChangedTo support OneWay and TwoWay bindings, the underlying data must implement INotifyPropertyChanged. 有关详细信息,请参阅 如何:实现属性更改通知For details, see How to: Implement Property Change Notification.

对于 TwoWayOneWayToSource 绑定,可以通过设置属性来控制目标到源更新 UpdateSourceTriggerFor TwoWay or OneWayToSource bindings, you can control the target-to-source updates by setting the UpdateSourceTrigger property. 有关详细信息,请参阅 UpdateSourceTriggerFor more information, see UpdateSourceTrigger.

有关不同绑定模式的详细信息,请参阅 数据绑定概述For more information on the different binding modes, see Data Binding Overview.

适用于