BindingExpression 类


包含有关 Binding 的单个实例的信息。Contains information about a single instance of a Binding.

public ref class BindingExpression sealed : System::Windows::Data::BindingExpressionBase, System::Windows::IWeakEventListener
public sealed class BindingExpression : System.Windows.Data.BindingExpressionBase, System.Windows.IWeakEventListener
type BindingExpression = class
    inherit BindingExpressionBase
    interface IWeakEventListener
Public NotInheritable Class BindingExpression
Inherits BindingExpressionBase
Implements IWeakEventListener


Binding 类是绑定的声明的高级类。The Binding class is the high-level class for the declaration of a binding. BindingExpression 类是维护绑定源和绑定目标之间的连接的基础对象。The BindingExpression class is the underlying object that maintains the connection between the binding source and the binding target. Binding 包含可跨多个 BindingExpression 对象共享的所有信息。A Binding contains all the information that can be shared across several BindingExpression objects. BindingExpression 是无法共享并包含有关 Binding的所有实例信息的实例表达式。A BindingExpression is an instance expression that cannot be shared and that contains all the instance information about the Binding.

例如,请考虑以下情况,其中 myDataObjectMyData 类的实例,myBinding 是源 Binding 对象,而 MyData 类是一个定义的类,其中包含名为 MyDataProperty的字符串属性。For example, consider the following, where myDataObject is an instance of the MyData class, myBinding is the source Binding object, and MyData class is a defined class that contains a string property named MyDataProperty. 此示例将 mytext的文本内容绑定到要 MyDataPropertyTextBlock的实例。This example binds the text content of mytext, which is an instance of TextBlock, to MyDataProperty.

// Make a new source.
MyData myDataObject = new MyData(DateTime.Now);      
Binding myBinding = new Binding("MyDataProperty");
myBinding.Source = myDataObject;
// Bind the new data source to the myText TextBlock control's Text dependency property.
myText.SetBinding(TextBlock.TextProperty, myBinding);
' Make a new source.
Dim data1 As New MyData(DateTime.Now)
Dim binding1 As New Binding("MyDataProperty")
binding1.Source = data1
' Bind the new data source to the myText TextBlock control's Text dependency property.
Me.myText.SetBinding(TextBlock.TextProperty, binding1)

您可以使用同一个 myBinding 对象创建其他绑定。You can use the same myBinding object to create other bindings. 例如,可以使用 myBinding 对象将复选框的文本内容绑定到 MyDataPropertyFor example, you might use the myBinding object to bind the text content of a check box to MyDataProperty. 在这种情况下,将有两个 BindingExpression 实例,它们共享 myBinding 对象。In that scenario, there will be two instances of BindingExpression that share the myBinding object.

您可以通过对数据绑定对象使用 GetBindingExpression 方法或 GetBindingExpression 方法来获取 BindingExpression 对象。You can obtain a BindingExpression object by using the GetBindingExpression method or the GetBindingExpression method on a data-bound object.



获取此 BindingGroup 绑定表达式所属的轴。Gets the BindingGroup that this binding expression belongs to.

(继承自 BindingExpressionBase)

获取此 BindingExpression 使用的绑定源对象。Gets the binding source object that this BindingExpression uses.


获取一个值,该值指示父绑定是否具有一个失败的验证规则。Gets a value that indicates whether the parent binding has a failed validation rule.

(继承自 BindingExpressionBase)

获取一个值,该值指示父绑定是否具有一个失败的验证规则。Gets a value that indicates whether the parent binding has a failed validation rule.

(继承自 BindingExpressionBase)

获取或设置指示绑定目标是否包含尚未写入到源中的值的值。Gets or sets a value that indicates whether the target of the binding has a value that has not been written to the source.

(继承自 BindingExpressionBase)

返回当前 BindingBindingExpression 对象。Returns the Binding object of the current BindingExpression.


获取从中创建此 BindingBase 对象的 BindingExpressionBase 对象。Gets the BindingBase object from which this BindingExpressionBase object is created.

(继承自 BindingExpressionBase)

获取该 BindingExpression 的绑定源对象。Gets the binding source object for this BindingExpression.


获取BindingExpression 的获取绑定源属性的名称。Gets the name of the binding source property for this BindingExpression.


获取绑定表达式的状态。Gets the status of the binding expression.

(继承自 BindingExpressionBase)

获取该绑定表达式的绑定目标对象元素。Gets the element that is the binding target object of this binding expression.

(继承自 BindingExpressionBase)

获取此绑定表达式的绑定目标属性。Gets the binding target property of this binding expression.

(继承自 BindingExpressionBase)

获取导致 ValidationError 的此实例无效的 BindingExpressionBaseGets the ValidationError that caused this instance of BindingExpressionBase to be invalid.

(继承自 BindingExpressionBase)

获取导致 ValidationError 实例无效的 BindingExpressionBase 集合。Gets a collection of ValidationError objects that caused this instance of BindingExpressionBase to be invalid.

(继承自 BindingExpressionBase)



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

(继承自 Object)

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

(继承自 Object)

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

(继承自 Object)

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

(继承自 Object)

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

将当前绑定目标值发送到 TwoWayOneWayToSource 绑定中的绑定源属性。Sends the current binding target value to the binding source property in TwoWay or OneWayToSource bindings.


强制将数据从绑定源属性传输到绑定目标属性。Forces a data transfer from the binding source property to the binding target property.


对关联的 ValidationRule 运行 Binding 属性设置为 ValidationStepRawProposedValue 的任何 ConvertedProposedValue 对象。Runs any ValidationRule objects on the associated Binding that have the ValidationStep property set to RawProposedValue or ConvertedProposedValue. 此方法不更新源。This method does not update the source.

(继承自 BindingExpressionBase)


IWeakEventListener.ReceiveWeakEvent(Type, Object, EventArgs)

此成员支持 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.