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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.