O'Reilly logo

Mastering Windows 8 C++ App Development 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 collections

The previous examples used a property that binds to a single object. As we've seen in the previous chapter, a bunch of controls deriving from ItemsControl can present information for more than one data item. It stands to reason that these controls should bind to a collection of data items, such as a collection of the Person objects.

The property to be used for binding purposes is ItemsSource. This should be set to a collection, typically IVector<T>. Here's an example of some Person objects bound to a ListView (a constructor was added to person for convenient initialization):

auto people = ref new Vector<Person^>; people->Append(ref new Person(L"Bart", L"Simpson", 1990)); people->Append(ref new Person(L"Lisa", L"Simpson", 1987)); ...

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