* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
1.9 KiB
title, ms.date, helpviewer_keywords, ms.assetid
| title | ms.date | helpviewer_keywords | ms.assetid | ||
|---|---|---|---|---|---|
| How to: Get the Binding Object from a Bound Target Property | 03/30/2017 |
|
87974c5f-136b-4de7-b07d-9285b62ab123 |
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 xref:System.Windows.Data.Binding object:
[!code-csharpBindValidation#GetBinding]
Note
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 xref:System.Windows.Data.BindingExpression and then get the value of the xref:System.Windows.Data.BindingExpression.ParentBinding%2A property.
For the complete example see Binding Validation Sample.
Note
If your binding is a xref:System.Windows.Data.MultiBinding, use xref:System.Windows.Data.BindingOperations.GetMultiBinding%2A?displayProperty=nameWithType. If it is a xref:System.Windows.Data.PriorityBinding, use xref:System.Windows.Data.BindingOperations.GetPriorityBinding%2A?displayProperty=nameWithType. If you are uncertain whether the target property is bound using a xref:System.Windows.Data.Binding, a xref:System.Windows.Data.MultiBinding, or a xref:System.Windows.Data.PriorityBinding, you can use xref:System.Windows.Data.BindingOperations.GetBindingBase%2A?displayProperty=nameWithType.