--- title: "How to: Implement PriorityBinding" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "data binding [WPF], PriorityBinding class" ms.assetid: d63b65ab-b3e9-4322-9aa8-1450f8d89532 --- # How to: Implement PriorityBinding in [!INCLUDE[TLA#tla_winclient](../../../includes/tlasharptla-winclient-md.md)] works by specifying a list of bindings. The list of bindings is ordered from highest priority to lowest priority. If the highest priority binding returns a value successfully when it is processed then there is never a need to process the other bindings in the list. It could be the case that the highest priority binding takes a long time to be evaluated, the next highest priority that returns a value successfully will be used until a binding of a higher priority returns a value successfully. ## Example To demonstrate how works, the `AsyncDataSource` object has been created with the following three properties: `FastDP`, `SlowerDP`, and `SlowestDP`. The get accessor of `FastDP` returns the value of the `_fastDP` data member. The get accessor of `SlowerDP` waits for 3 seconds before returning the value of the `_slowerDP` data member. The get accessor of `SlowestDP` waits for 5 seconds before returning the value of the `_slowestDP` data member. > [!NOTE] > This example is for demonstration purposes only. The .NET guidelines recommend against defining properties that are orders of magnitude slower than a field set would be. For more information, see [Choosing Between Properties and Methods](/previous-versions/dotnet/netframework-4.0/ms229054(v=vs.100)). [!code-csharp[PriorityBinding#1](~/samples/snippets/csharp/VS_Snippets_Wpf/PriorityBinding/CSharp/Window1.xaml.cs#1)] [!code-vb[PriorityBinding#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PriorityBinding/VisualBasic/AsyncDataSource.vb#1)] The property binds to the above `AsyncDS` using : [!code-xaml[PriorityBinding#2](~/samples/snippets/csharp/VS_Snippets_Wpf/PriorityBinding/CSharp/Window1.xaml#2)] When the binding engine processes the objects, it starts with the first , which is bound to the `SlowestDP` property. When this is processed, it does not return a value successfully because it is sleeping for 5 seconds, so the next element is processed. The next does not return a value successfully because it is sleeping for 3 seconds. The binding engine then moves onto the next element, which is bound to the `FastDP` property. This returns the value "Fast Value". The now displays the value "Fast Value". After 3 seconds elapses, the `SlowerDP` property returns the value "Slower Value". The then displays the value "Slower Value". After 5 seconds elapses, the `SlowestDP` property returns the value "Slowest Value". That binding has the highest priority because it is listed first. The now displays the value "Slowest Value". See for information about what is considered a successful return value from a binding. ## See also - - [Data Binding Overview](data-binding-overview.md) - [How-to Topics](data-binding-how-to-topics.md)