20.1. Data Binding Redux

In most data binding scenarios, you aren't binding to a single object but to an entire collection. Figure 20-1 shows a familiar example—a form with a list of products. When the user selects a product, its details appear on the right.

Figure 20.1. Browsing a collection of products

In Chapter 19, you learned to build exactly this sort of form. Here's a quick review of the basic steps:

  1. First you need to create the list of items, which you can show in an ItemsControl. Set the DisplayMemberPath to indicate the property (or field) you want to show for each item in the list. This list shows the model name of each item:

    <ListBox ...

Get Pro WPF in C# 2010: Windows Presentation Foundation in .NET 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.