C H A P T E R  11

Advanced Data Binding

So far in this book, you've learned how to bind your user interface controls to objects so that the user can view and edit data exposed by these objects. Instead of data being pushed into these controls, the extensive data binding support provided by XAML enables controls to pull the data into themselves. In other words, the controls are essentially controlling the process of consuming the data. You've learned that

  • The object assigned to the DataContext property of a control is inherited down the object hierarchy.
  • There are three different binding modes: OneTime, OneWay, and TwoWay (discussed in Chapter 2). You need to set the mode to TwoWay to update the bound object property via a control in the user interface.
  • You can notify the bindings when bound property values on an object have changed, using the INotifyPropertyChanged interface, discussed in Chapter 7.
  • You can notify the bindings when bound property values (or the bound object itself) are invalid by throwing exceptions, implementing the IDataErrorInfo interface, or by implementing the INotifyDataErrorInfo interface, as discussed in Chapter 7.
  • The ObservableCollection<T> type can be used to maintain items in your collections, which will notify the bound user interface controls when items have been added or removed from the collection so they can update themselves accordingly (discussed in Chapter 6). Alternatively, you can implement the INotifyCollectionChanged interface in your own collection classes to enable them to exhibit the same behavior.
  • You can create a view of a collection by wrapping it in a collection view, enabling the data in the collection to be manipulated (e.g., filtered, sorted, grouped, and paged) without actually modifying the underlying collection (discussed in Chapter 6). Collection views also provide a current record pointer that tracks the current item in the collection, enabling multiple controls bound to the same collection view to be kept synchronized. They also provide the ability to move this pointer and navigate through the items in the collection.

To develop business applications in Silverlight effectively, you need to have a thorough knowledge of the available data binding mechanisms at your disposal. In this chapter, we'll look at some of the advanced data binding features supported by Silverlight, and I'll provide you with tips, tricks, and techniques that you can use to harness the full power of Silverlight's data binding engine.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset