Binding to a collection
The previous recipe showed how to bind various properties to a single object, using single data controls, such as
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.
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.
- Create a new WPF Application named