How Data Binding Works? - An Overview
data binding is the connection between the application UI and business logic.
There are lots of changes in data binding mechanism from .NET 2.0 to .NET 3.0.
Currently the data binding mechanism can be described using the XAML language.
There are new classes like 'Binding' which are introduced for data binding. The
data binding source can be anything ranging from common language runtime (CLR)
objects to XML files.
How the Data binding works?
A binding target could be a ContentControls such as Button or ItemsControls such as ListBox/ListView.
properties of binding target like background color or content can be bound to
binding source. This is the flexibility of the WPF. For example, in inventory
application background color of the list item can be set to red or green depending
on stock qty.
The binding source is data provider like data base object or XML files.
Binding is the class, which bridges the Binding source and Binding target.
property 'UpdateSourceTriger' must be set, which determine when data should flow
from binding source to binding target. The below table show the possible values
for this property.
The example below shows how to bind background color of the button.
Specifying the Path to the Value
For object data source Path property can be used for specify the binding. For XML data, XPath propertycan be used. In some cases, it may be applicable to use the Path property even when your data is XML. XPath and Path both can be used specify data source, where Path can used to specify a property in the XML Node returned by the XPath property.
Below is an example for data binding, where the List Control's 'ItemSource' property is used to set the binding property.
above example illustrates how to bind the collection of data items to the list
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage