This article presents information about Data binding, which is a mechanism in WPF Applications, which provides a simple and easy way for Windows Runtime apps to display and interact with the data.
Introduction
Data binding is a mechanism in WPF Applications, which provides a simple and easy way for Windows Runtime apps to display and interact with the data.
Data binding is of two types- One-Way Data binding and Two-Way Data binding.
One-Way Data binding
In One-Way binding, the data is bound from its source (that is the object that holds the data) to its target (that is the object, which displays the data).
This is because Data binding mode is set to One-Way in XAML code. To show the updated data, you will need to understand Two-Way data binding.
Two-Way Data binding
In Two-Way binding, the user can modify the data through the user interface and have the data updated in the source. If the source changes while the user is looking at the View, you want the View to be updated.
Let’s take the same example but here, we will change the binding mode from One Way to Two Way in XAML code.
Let's run this Application again.
It will produce the same output.
Let’s change the Name and Age values, as given below.
If you click Show button now, it will display the updated message.
We recommend that you execute the code given above with both the cases for a better understanding of the concept.
Pro WPF: Windows Presentation Foundation in .NET 3.0