O'Reilly logo

Windows Presentation Foundation 4.5 Cookbook by Pavel Yosifovich

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

Binding to a collection

The previous recipe showed how to bind various properties to a single object, using single data controls, such as TextBlock, TextBox, or Button. Some controls, however, are capable of displaying multiple object data, such as a ListBox. These controls can bind to a collection of data objects, and with the help of data templates and value converters (to be covered in later recipes), become a powerful visualization tool. Let's examine the basic ideas of binding to collection of objects.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create a collection of Person object and bind them to a ListBox, showing the details we need to take care of.

  1. Create a new WPF Application named CH06.BindingToCollection ...

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