DataGrid for WPF and Silverlight Overview > DataGrid Features > Sorting |
Sorting grid columns at run time is simple in DataGrid for WPF. To sort columns click once on the header of the column that you wish to sort.
You will notice that the sort glyph, a sort direction indicator, appears when a column is sorted:
You can click once again on the column header to reverse the sort; notice that the sort glyph changes direction.
Sort multiple columns by sorting one column and then holding the CTRL key while clicking on a second column header to add that column to your sort condition. For example, in the following image the Category column was first sorted, and then the Name column was reverse sorted:
Note that the CanUserSort property must be set to True (default) for sorting to be possible.