Chapter 3. Modes and Notifications

Chapter 2 demonstrated the foundations of data-binding functionality in Silverlight 2 using the DataContext property and runtime binding techniques through both Visual Studio and Expression Blend. All of the examples in Chapter 2 used the default binding mode of OneWay, which tells the bindings to push values from the source to the target when the source values change. The binding modes and their related functionality are a critical piece of the data-binding component. The binding modes make it very easy to support the binding of a source to a target and a target back to a source, if appropriate. A control’s binding can indicate that it should be bound source to the target, for read-only data, or the control can designate that the binding should flow in both directions, thus making the control and its data values user-editable.

Two of the key sources of the power of XAML-based data binding are the INotifyPropertyChanged interface and the INotifyCollectionChanged interface. These interfaces provide the means for data source objects to let data bindings know that something about the source has changed. The ObservableCollection<T> implements the INotifyCollectionChanged interface, which yields a collection class that is able to provide notifications when items in the collection change.

Chapter 2 demonstrated how to bind a single-entity object source to a series of Silverlight 2 controls through various means, including inheriting a DataContext ...

Get Data-Driven Services with Silverlight 2 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.