BindingMode 枚举

定义

描述绑定中数据流的方向。Describes the direction of the data flow in a binding.

public enum class BindingMode
public enum BindingMode
type BindingMode = 
Public Enum BindingMode
继承
BindingMode

字段

Default 4

使用绑定目标的默认 Mode 值。Uses the default Mode value of the binding target. 每个依赖属性的默认值都不同。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.

OneTime 2

在应用程序启动或数据上下文更改时,更新绑定目标。Updates the binding target when the application starts or when the data context changes. 如果你在适合使用当前状态的快照或数据实际为静态数据的位置使用数据,则此类型的绑定适合。This type of binding is appropriate if you are using data where either a snapshot of the current state is appropriate to use or the data is truly static. 如果你想使用源属性中的某个值来初始化目标属性,且提前不知道数据上下文,则此类型的绑定也有用。This type of binding is also useful if you want to initialize your target property with some value from a source property and the data context is not known in advance. 这是实质上是 OneWay 绑定的一种简化形式,它在源值不更改的情况下提供更好的性能。This is essentially a simpler form of OneWay binding that provides better performance in cases where the source value does not change.

OneWay 1

在更改绑定源(源)时更新绑定目标(目标)。Updates the binding target (target) property when the binding source (source) changes. 如果绑定的控件为隐式只读,则此类型的绑定适用。This type of binding is appropriate if the control being bound is implicitly read-only. 例如,你可能绑定到股票代码等源。For instance, you may bind to a source such as a stock ticker. 或者可能是未向目标属性提供控件接口来进行更改,例如表的数据绑定背景色。Or perhaps your target property has no control interface provided for making changes, such as a data-bound background color of a table. 如果无需监视目标属性的更改,则使用 OneWay 绑定模式可避免 TwoWay 绑定模式的系统开销。If there is no need to monitor the changes of the target property, using the OneWay binding mode avoids the overhead of the TwoWay binding mode.

OneWayToSource 3

在目标属性更改时,更新源属性。Updates the source property when the target property changes.

TwoWay 0

导致更改源属性或目标属性时自动更新另一方。Causes changes to either the source property or the target property to automatically update the other. 此类型的绑定适用于可编辑窗体或其他完整交互式的 UIUI 方案。This type of binding is appropriate for editable forms or other fully-interactive UIUI scenarios.

适用于

另请参阅