Data Binding is one of the greatest and most powerful features of XAML (WPF, Silverlight, Windows Phone or Windows 8) compared to other traditional web and Windows app technology in .NET. There was simple data binding for displaying single values, and complex data binding for displaying and formatting a bunch of data. XAML (WPF, Silverlight, Windows Phone or Windows 8 ) however makes it easy to bind nearly any property to any element or object or data source. You take data from some property or object or dependency property and bind it to another dependency property or object or else directly to an element. In a single word you can say in XAML "Data binding is the process of getting information from one object to another and displaying it in one or more elements in the user interface".
How {Binding} works in WPF
The Binding keyword looks as in the following image. Here is the binding of TextBox UI controls with some binding property source object.
Binding to a WPF element from code behind.
In the above sample a TextBox and slider from code behind using some binding property.
Some Very Useful Properties of the Binding Class
Property Name |
Description |
Element Name |
The name of the element that gets or sets the binding source object when binding to a XAML element. |
FallbackValue |
Set the value to use when the binding does not return values. |
Converter |
Set the converter for the UI element. |
Mode |
Set the Binding diection between the target and source objects. |
Path |
Get or Set the path to the source property of the Binding source. |
RelativeSource |
Gets or Sets the binding source by specifying it's location and relative to the postion of the binding target. |
Source |
Gets or Sets the binding source when not binding to a WPF element. |
StringFormat |
|
UpdateSourceTrigger |
|
ValidationRules |
|
NotifyOnSourceUpdated |
Gets or sets the value determining the direction of the dataflow in the binding. |
NotifyOnTargetUpdated |
Gets or sets a value that indicates whether to raise the source Update event when a value is transferred from the source to the target. |