Chapter 36. Business Applications with WPF

WHAT'S IN THIS CHAPTER?

  • Data Binding to Elements, Objects, Lists, and XML

  • Value Conversions and Validation

  • Commanding

  • Using the TreeView to display hierarchical data

  • Displaying and Grouping data with the DataGrid

In the previous chapter you read about some of the core functionality of WPF. In this chapter the journey through WPF continues. Here you read about important aspects for creating complete applications, such as data binding and command handling, and about the new DataGrid control. Data binding is an important concept to bring data from .NET classes into the user interface, and allow the user to change data. Commanding allows mapping events from the UI to code. In contrast to the event model, this gives a better separation between XAML and code. The TreeView and DataGrid controls are UI controls to display bound data.

DATA BINDING

WPF data binding takes another huge step forward compared with previous technologies. Data binding gets data from .NET objects to the UI or the other way around. Simple objects can be bound to UI elements, lists of objects, and also XAML elements itself. With WPF data binding, the target can be any dependency property of a WPF element, and every property of a CLR object can be the source. Because a WPF element is implemented as a .NET class, every WPF element can be the source as well. See Figure 36-1 for the connection between the source and the target. The Binding object defines the connection.

Figure 36.1. FIGURE ...

Get Professional C# 4 and .NET 4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.