Grouping bound collections

The previous recipe used the ICollectionView source for sorting, filtering, and navigating. Another useful feature of ICollectio nView 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"> ...

Get Windows Presentation Foundation 4.5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.