Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SortMemberPath Property

DataGridColumn.SortMemberPath Property

Gets or sets a property name, or a period-delimited hierarchy of property names, that indicates the member to sort by.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

public string SortMemberPath { get; set; }
<sdk:dataGridColumn SortMemberPath="path"/>

XAML Values

sdk:dataGridColumn

Typically, sdk:DataGridTextColumn, sdk:DataGridCheckBoxColumn, or sdk:DataGridTemplateColumn.

path

A string that describes the target property. This can be a simple property name, or a property path to a sub-property.

Property Value

Type: System.String
The path to the data-item member to sort by.

In columns that are derived from DataGridBoundColumn, such as DataGridTextColumn and DataGridCheckBoxColumn, the SortMemberPath is set to the property that the column is bound to through the Binding property by default. In columns that are derived from DataGridColumn, such as DataGridTemplateColumn, the SortMemberPath property must be set to enable automatic sorting of the column.

The following code example demonstrates how to set the SortMemberPath property. This example is part of a larger example available in the How to: Customize Auto-Generated Columns in the DataGrid Control topic.


// Create a new template column.
DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();
templateColumn.Header = "Due Date";
templateColumn.CellTemplate = (DataTemplate)Resources["dueDateCellTemplate"];
templateColumn.CellEditingTemplate = (DataTemplate)Resources["dueDateCellEditingTemplate"];
templateColumn.SortMemberPath = "DueDate";


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft