Data Binding is one of the greatest and most powerful features of XAML as 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 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 "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".
Binding is all about connecting a source to a target. Every time you use binding you must supply a source for the data and the target. Generally the target is a dependency property or some framework element of some user interface and the binding source can be any CLR object. Between the source and the target more objects are involved called value converters. This conversion represents an instance of a class that is implemented for doing the binding declaratively. XAML often requires value conversion using the Ivalueconverter interface.
Binding Object
Source Object
In a single "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".
Binding is all about connecting a source to a target. Every time you use binding you must supply a source for the data and the target. Generally the target is a dependency property or some framework element of some user interface and the binding source can be any CLR object. Between the source and the target more objects are involved called value converters. This conversion represents an instance of a class that is implemented for doing the binding declaratively. XAML often requires value conversion using the Ivalueconverter interface.
Target Object
This is a complete UI Control or UI element where you can display your data. You cannot directly bind to the target object; it needs a dependency property or object or UI object.
Binding Object
This works between a target and a source object, you can specify data context binding mode converter and so on.
Source Object
Your data that you want to show on the UI is a source object, it can be any type (CLR object or some other object). Generally we use a CLR object or web service XML, LINQ or list<T>.
Binding Modes in XAML
OneWay
Data moves only one direction, the source property automatically updates the target property but the source is not changed.
TwoWay
TwoWay
Data moves both directions, if you change it in the source or target it is automatically updated to the other.
OneWayToSource
OneWayToSource
Data moves from the target to the source changes to the target property to automatically update the source property but the target is not changed .
OneTime
OneTime
Data is changed only one time and after that it is never set again, only the first time changes to the source property automatically update the target property but the source is not changed and subsequent changes do not affect the target property
No comments:
Post a Comment