Chapter 11. Data binding with WPF
This chapter covers:
- Binding to objects
- Binding to XML
- Binding to ADO.NET
- Binding to LINQ
- Binding spells for system daemons
Now that we have a user interface and a way to drive it, we need to put some data behind it—otherwise, it isn’t likely to be terribly useful. Before we get to modifying the Desktop Wiki application, we first want to explore data binding more generally; the easiest way is to build some small utilities that will make use of data binding. Once we’ve done that we’ll return to the wiki and give it some data. The first example we’ll show is a process monitor (figure 11.1). It binds to the list of processes currently running on the system. This first version of the process monitor is relatively ugly, but we’ll return to it in chapter 12, where we’ll make it really ugly.
Figure 11.1. The Process Monitor application demonstrates binding to a collection returned by a method call.

Next, we’ll demonstrate binding to XML with our Common Vulnerabilities and Exposures (CVE) viewer. As you’ll see, binding to XML in WPF is extremely easy. Binding to ADO.NET data, such as from a DataTable, will be demonstrated using a simple Bookmark application. We’ll also talk a bit about binding to data returned from a LINQ query. Finally, we’ll get back to the Desktop Wiki application that allows various notes to be entered, categorized, and stored.