Events
17 Mar, 21 - 21 Mar, 10
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
You use the Binding.Mode property to specify the direction of the binding. The following are the available options for binding updates:
BindingMode.TwoWay updates the target property or the property whenever either the target property or the source property changes.
BindingMode.OneWay updates the target property only when the source property changes.
BindingMode.OneTime updates the target property only when the application starts or when the DataContext undergoes a change.
BindingMode.OneWayToSource updates the source property when the target property changes.
BindingMode.Default causes the default Mode value of target property to be used.
For more information, see the BindingMode enumeration.
The following example shows how to set the Mode property.
<TextBlock Name="IncomeText" Grid.Row="0" Grid.Column="1"
Text="{Binding Path=TotalIncome, Mode=OneTime}"/>
To detect source changes (applicable to OneWay and TwoWay bindings), the source must implement a suitable property change notification mechanism such as INotifyPropertyChanged. See Implement Property Change Notification for an example of an INotifyPropertyChanged implementation.
For TwoWay or OneWayToSource bindings, you can control the timing of the source updates by setting the UpdateSourceTrigger property. See UpdateSourceTrigger for more information.
.NET Desktop feedback feedback
.NET Desktop feedback is an open source project. Select a link to provide feedback:
Events
17 Mar, 21 - 21 Mar, 10
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowDocumentation
How to: Control When the TextBox Text Updates the Source - WPF .NET Framework
Control the timing of binding source updates using the UpdateSourceTrigger property in Windows Presentation Foundation (WPF).
How to: Create a Binding in Code - WPF .NET Framework
Learn how to create a binding in code in a Windows Presentation Foundation application by calling the SetBinding method directly.
How to: Specify the Binding Source - WPF .NET Framework
Learn how to specify the binding source through this example in the Windows Presentation Foundation (WPF).