Chapter 12. Advanced data templates and binding

 

This chapter covers:

  • Data templates
  • StringFormat
  • Sorting and filtering data
  • Validating data
  • Model-View-ViewModel
  • Hierarchical, multiple, and priority binding
  • Making your computer sound like Tinky Winky

The idea of data binding has been around in one form or another for a long time. Arguably, the WPF model is better in many respects, but something that really makes WPF binding shine (sometimes literally) is the ability to create complex templates that control the way data is displayed, based on that data, via data templates. There were some simple examples in the previous chapter, but we’re going to get a lot fancier (figure 12.1).

Figure 12.1. The Process Monitor application from the last chapter, but with a much fancier template for displaying the tasks as cards, as well as nicer displays for numbers. High priority tasks are shown in red, and the user can choose how to sort the items and filter them based on priority—all done with data templates and features of binding.

While we’re about it, we’re also going to show some additional binding capabilities such as binding to hierarchical data, doing virtualized binding, and even binding to more than one thing at a time.

12.1. Data converters

12.2. DataTriggers

12.3. CollectionViewSource

12.4. Conditional templates

12.5. Validators

12.6. Model-View-ViewModel

12.7. Advanced binding capabilities

12.8. Summary

sitemap