Sorting and grouping data in a DataGrid

Sorting the values within a column in a control such as a DataGrid is something that we take for granted. Silverlight's implementation has some very strong sorting options working out of the box for us. It allows us to sort by clicking on the header of a column, amongst other things.

Along with sorting, the DataGrid enables the grouping of values. Items possessing a particular property (that is, in the same column) and having equal values can be visually grouped within the DataGrid.

All of this is possible by using a view on top of the bound collection. In this recipe, we'll look at how we can leverage this view to customize the sorting and grouping of data within the DataGrid.

Getting ready

This sample continues ...

Get Silverlight 4 Data and Services 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.