PriorityBinding 类

定义

描述附加到单个绑定目标属性的 Binding 对象的集合,该属性从成功生成值的集合中的第一个绑定接收其值。Describes a collection of Binding objects that is attached to a single binding target property, which receives its value from the first binding in the collection that produces a value successfully.

public ref class PriorityBinding : System::Windows::Data::BindingBase, System::Windows::Markup::IAddChild
[System.Windows.Markup.ContentProperty("Bindings")]
public class PriorityBinding : System.Windows.Data.BindingBase, System.Windows.Markup.IAddChild
type PriorityBinding = class
    inherit BindingBase
    interface IAddChild
Public Class PriorityBinding
Inherits BindingBase
Implements IAddChild
继承
属性
实现

注解

PriorityBinding允许您将绑定目标 (目标) 属性与绑定列表相关联。PriorityBinding lets you associate a binding target (target) property with a list of bindings. 成功返回值的第一个绑定将成为活动绑定。The first binding that returns a value successfully becomes the active binding.

如果以下情况, 绑定将成功返回值:A binding returns a value successfully if:

  1. 绑定源的路径解析成功。The path to the binding source resolves successfully.

  2. 值转换器 (如果有) 能够转换结果值。The value converter, if any, is able to convert the resulting value.

  3. 结果值对于目标属性有效。The resulting value is valid for the target property.

该值DependencyProperty.UnsetValue不被视为成功的返回值。The value DependencyProperty.UnsetValue is not considered a successful return value.

绑定的优先级由其在列表中的顺序确定。The priority of the bindings is determined by their order in the list. 列表中第一个出现的绑定具有最高优先级。The binding that appears first in the list has the highest priority.

绑定引擎以列表中的第一个绑定开头, 并验证该绑定是否成功返回值;如果是这样, 则使用来自该绑定的值。The binding engine starts with the first binding in the list and verifies whether that binding returns a value successfully; if it does, the value from that binding is used. 如果第一个绑定未成功返回值, 则绑定引擎会检查第二个绑定, 以确定它是否成功返回值;如果是这样, 则第二个绑定中的值将成为活动值。If the first binding does not return a value successfully, the binding engine examines the second binding to determine whether it returns a value successfully; if it does, the value from the second binding becomes the active value. 此验证过程将继续到绑定列表的末尾。This verification process continues to the end of the list of bindings. 如果没有任何绑定成功返回值, 则绑定将使用FallbackValueIf none of the bindings returns a value successfully, the binding uses the FallbackValue.

绑定引擎继续侦听所有绑定的更改。The binding engine continues to listen for changes on all bindings. 如果任何一个具有较高优先级的绑定都成功返回值, 则该绑定的值将成为活动值并替换当前值。If at any point one of the bindings that has a higher priority returns a value successfully, the value for that binding becomes the active value and replaces the current value.

构造函数

PriorityBinding()

初始化 PriorityBinding 类的新实例。Initializes a new instance of the PriorityBinding class.

属性

BindingGroupName

获取或设置此绑定所属的 BindingGroup 的名称。Gets or sets the name of the BindingGroup to which this binding belongs.

(继承自 BindingBase)
Bindings

获取 Binding 对象的集合,该集合是为 PriorityBinding 的此实例建立的。Gets the collection of Binding objects that is established for this instance of PriorityBinding.

Delay

获取或设置更新位于目标更改上的值之后的绑定源前要等待的时间(毫秒)。Gets or sets the amount of time, in milliseconds, to wait before updating the binding source after the value on the target changes.

(继承自 BindingBase)
FallbackValue

获取或设置当绑定无法返回值时要使用的值。Gets or sets the value to use when the binding is unable to return a value.

(继承自 BindingBase)
StringFormat

获取或设置一个字符串,该字符串指定如果绑定值显示为字符串,应如何设置该绑定的格式。Gets or sets a string that specifies how to format the binding if it displays the bound value as a string.

(继承自 BindingBase)
TargetNullValue

获取或设置当源的值为 null 时在目标中使用的值。Gets or sets the value that is used in the target when the value of the source is null.

(继承自 BindingBase)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ProvideValue(IServiceProvider)

返回一个应在应用了此绑定和扩展的属性上设置的对象。Returns an object that should be set on the property where this binding and extension are applied.

(继承自 BindingBase)
ShouldSerializeBindings()

返回一个值,该值指示序列化进程是否应当对此类的实例的 Bindings 有效属性值进行序列化。Returns a value that indicates whether serialization processes should serialize the effective value of the Bindings property on instances of this class.

ShouldSerializeFallbackValue()

返回一个值,该值指示序列化进程是否应当对此类的实例的 FallbackValue 有效属性值进行序列化。Returns a value that indicates whether serialization processes should serialize the effective value of the FallbackValue property on instances of this class.

(继承自 BindingBase)
ShouldSerializeTargetNullValue()

返回一个值,该值指示是否应序列化 TargetNullValue 属性。Returns a value that indicates whether the TargetNullValue property should be serialized.

(继承自 BindingBase)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

IAddChild.AddChild(Object)

此成员支持 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基础结构,但不能在代码中直接使用。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

IAddChild.AddText(String)

此成员支持 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基础结构,但不能在代码中直接使用。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

适用于

另请参阅