Professional C# 4 and .NET 4
by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner
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
TreeViewto display hierarchical dataDisplaying 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access