Data Binding
A data binding is a connection between the user interface and a business object or other data provider. The user interface object is called the target, and the provider of the data is called the source.
Data binding assists with the separation of the user-interface layer of your application from its other layers (business objects, data, and so forth).
Separation of the UI layer from the underlying layers is accomplished through a Binding
object, which has two modes: one-way and two-way. One-way binding displays data from the source in the target; two-way binding also updates the source in response to changes made in the user interface.
Binding to a Business Object
To see one-way and two-way binding at work, create a new Silverlight Application named BookDisplay. Add to the application a Book.cs file, which will represent the business layer.
What separates a Silverlight business object from one created for a platform like ASP.NET is that you want the business object to participate in one-way or two-way binding with the UI layer. If you want the UI to be updated every time the business object changes (for example, if the quantity on hand changes), the business object must implement the INotifyPropertyChanged
interface. This interface requires the class to have an event of the type PropertyChangedEventHandler
(named PropertyChanged
by convention). Implicit in supporting binding, however, is that your business object must, by convention, fire the PropertyChanged
event when any ...
Get Programming .NET 3.5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.