Chapter 11. Binding

 

This chapter covers

  • Mastering binding with a binding source
  • Binding UI elements together
  • Using value converters
  • Creating data templates

If I included a top-three list of the most important features to learn in-depth in Silverlight or WPF, binding would be on that list. Binding—specifically, data binding—tends to conjure up images of the old Visual Basic VCR control bound directly to tables in an Access database, mishandled lost-focus events, and circular validation problems. In more recent times, binding tends to be associated with specialized data controls on web forms. In both cases, binding is associated with traditional business or application data on its way to or from a persistent data store.

Though binding is most commonly thought of in relation to persistent application or business data, it’s used for much more than that in Silverlight and WPF.

In Silverlight and WPF, you can bind properties such as IsEnabled to bool values hanging off any arbitrary object. You can also bind controls to each other so that, for example, a slider controls the z-axis rotation of an object in 3D space. Neither of those properties (IsEnabled or z rotation) would normally be thought of as “data” in a data binding sense but, in the strictest sense of the term, they are.

Want to show the number of characters entered in a TextBox? You guessed it: binding will help you do that with no code required.

11.1. Binding with your data

 
 

11.2. Understanding your binding source

 
 
 

11.3. Customizing the display

 

11.4. Creating data templates

 
 
 

11.5. Summary

 
 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage