O'Reilly logo

Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data Binding Redux

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

Browsing a collection of products

In Chapter 16, 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 Name="lstProducts" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required