O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

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

Populating a Pivot Via a Data Bound Collection

This second example looks at using a collection of viewmodels to dynamically populate a Pivot using a DataTemplate. The result of this example is the same as the previous example, except in this case the PivotItems are dynamically created based on their data type. This provides some added flexibility that can be useful in larger apps.

The example code for this section is located in the files DataboundPivotView.xaml, DataboundPivotView.xaml.cs, and DataboundPivotViewModel.cs in the downloadable sample code.

In this example the viewmodel has been changed from exposing two child viewmodel properties to a collection of viewmodels (see Listing 11.5).

LISTING 11.5. DataboundPivotViewModel Class

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