| Visual Basic (Declaration) | |
|---|---|
Public Property SortComparer As IComparer | |
| C# | |
|---|---|
public IComparer SortComparer {get; set;} | |
Return Value
The IComparer that will be used to sort the values of the DataGridItemProperty's associated column. Can be a null reference (Nothing in Visual Basic).All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
The following example demonstrates how to provide a custom sort comparer that sorts addresses. The AddressComparer class (provided below) will first sort addresses which begin with numeric values by street name and then civic number. Address that do not have a civic number will be sorted alphabetically.
| XAML | Copy Code |
|---|---|
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" | |
The following code provides the implementation of the AddressComparer class.
| Visual Basic | Copy Code |
|---|---|
Imports System | |
The following code provides the implementation of the AddressComparer class.
| C# | Copy Code |
|---|---|
using System; | |
If a null reference (Nothing in Visual Basic), the default comparer will be used.
Supported Frameworks: Microsoft .NET Framework version 3.5
Copy Code