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

Grouping bound collections

The previous recipe used the ICollectionView source for sorting, filtering, and navigating. Another useful feature of ICollectionView is grouping. This allows the partitioning of the data into groups based on some criteria (typically a property). Each such group is subject to sorting and/or filtering, if used.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll use the same collection of process objects used previously, but this time we'll group them by some criteria.

  1. Create a new WPF Application named CH06.GroupingData.
  2. Open MainWindow.xaml. Add a ListBox to the existing grid, with a simple data template to display information on process objects:
    <ListBox ItemsSource="{Binding}" HorizontalContentAlignment="Stretch"> ...

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