The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataGrid.CanUserSortColumns Property

Gets or sets a value that indicates whether the user can sort columns by clicking the column header.

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

public bool CanUserSortColumns { get; set; }
<sdk:DataGrid CanUserSortColumns="bool"/>

Property Value

Type: System.Boolean
true if the user can sort columns; otherwise, false. The default is true.

Dependency property identifier field: CanUserSortColumnsProperty

You can set this behavior for individual columns by setting the DataGridColumn.CanUserSort property. If the DataGridColumn.CanUserSort property and the DataGrid.CanUserSortColumns property are both set, a value of false will take precedence over a value of true.

The following code example demonstrates how to set the CanUserSortColumns property in code. This example is part of a larger example available in the Walkthrough: Customizing the DataGrid Control Using Properties topic.

private void cbColSort_Changed(object sender, RoutedEventArgs e)
    CheckBox cb = sender as CheckBox;
    if (this.dataGrid1 != null)
        this.dataGrid1.CanUserSortColumns = (bool)cb.IsChecked;


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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft