Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Get the Binding Object from a Bound Target Property

This example shows how to obtain the binding object from a data-bound target property.

Example

You can do the following to get the Binding object:

// textBox3 is an instance of a TextBox
// the TextProperty is the data-bound dependency property
Binding myBinding = BindingOperations.GetBinding(textBox3, TextBox.TextProperty);

NoteNote:

You must specify the dependency property for the binding you want because it is possible that more than one property of the target object is using data binding.

Alternatively, you can get the BindingExpression and then get the value of the ParentBinding property.

For the complete example see Binding Validation Sample.

NoteNote:

If your binding is a MultiBinding, use BindingOperations.GetMultiBinding. If it is a PriorityBinding, use BindingOperations.GetPriorityBinding. If you are uncertain whether the target property is bound using a Binding, a MultiBinding, or a PriorityBinding, you can use BindingOperations.GetBindingBase.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft