Files
docs-desktop/dotnet-desktop-guide/framework/wpf/data/how-to-specify-the-direction-of-the-binding.md
T
Andy (Steve) De George e9fcf43083 Merge pull request #1135 from dotnet/adegeo-links
Correct .NET Framework links that pointed to old .NET 5 URLs
2021-08-11 12:04:34 -07:00

2.8 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Specify the Direction of the Binding 03/30/2017
direction of binding [WPF]
binding direction [WPF]
data binding [WPF], direction of binding
37334478-028b-4514-86c9-1420709f4818

How to: Specify the direction of the binding

This example shows how to specify whether the binding updates only the binding target (target) property, the binding source (source) property, or both the target property and the source property.

Example

You use the xref:System.Windows.Data.Binding.Mode%2A?displayProperty=nameWithType property to specify the direction of the binding. The following are the available options for binding updates:

For more information, see the xref:System.Windows.Data.BindingMode enumeration.

The following example shows how to set the xref:System.Windows.Data.Binding.Mode%2A property.

[!code-xamlDirectionalBinding#4]

To detect source changes (applicable to xref:System.Windows.Data.BindingMode.OneWay and xref:System.Windows.Data.BindingMode.TwoWay bindings), the source must implement a suitable property change notification mechanism such as xref:System.ComponentModel.INotifyPropertyChanged. See Implement Property Change Notification for an example of an xref:System.ComponentModel.INotifyPropertyChanged implementation.

For xref:System.Windows.Data.BindingMode.TwoWay or xref:System.Windows.Data.BindingMode.OneWayToSource bindings, you can control the timing of the source updates by setting the xref:System.Windows.Data.Binding.UpdateSourceTrigger%2A property. See xref:System.Windows.Data.Binding.UpdateSourceTrigger%2A for more information.

See also