Back to Devexpress

ColumnBase.SortOrder Property

wpf-devexpress-dot-xpf-dot-grid-dot-columnbase-0301c223.md

latest5.9 KB
Original Source

ColumnBase.SortOrder Property

Gets or sets the column’s sort order. This is a dependency property.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
[Browsable(false)]
public ColumnSortOrder SortOrder { get; set; }
vb
<Browsable(False)>
Public Property SortOrder As ColumnSortOrder

Property Value

TypeDescription
ColumnSortOrder

The column’s sort order.

|

Available values:

NameDescription
None

No sorting is applied to a column.

| | Ascending |

Sorts the column in ascending order.

| | Descending |

Sorts the columns in descending order.

|

Remarks

To sort data against a column, specify its SortOrder property:

xaml
<dxg:GridColumn FieldName="City" SortOrder="Descending"/>
<dxg:GridColumn FieldName="Visits" SortOrder="Ascending"/>
<dxg:GridColumn FieldName="Birthday" SortOrder="None"/>

The SortOrder property does not clear the sorting applied. This property adds a new sorting condition to previous ones.

Refer to the Sorting in Code topic for more information.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SortOrder property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-display-group-summaries/CS/DisplayGroupSummaries_CodeBehind/MainWindow.xaml#L15

xml
<dxg:GridColumn FieldName="RegistrationDate" />
<dxg:GridColumn FieldName="Married" GroupIndex="0" SortOrder="Ascending" />
<dxg:GridColumn FieldName="Age" />

wpf-data-grid-getting-started-net-framework/CS/WPFDataGridGettingStartedNETFramework/MainWindow.xaml#L17

xml
<dxg:GridColumn FieldName="OrderID" IsSmart="True"/>
<dxg:GridColumn FieldName="CustomerID" IsSmart="True" SortIndex="0" SortOrder="Ascending"/>
<dxg:GridColumn FieldName="OrderDate" IsSmart="True" SortIndex="1" SortOrder="Descending"/>

wpf-data-grid-getting-started-dot-net/CS/WPFDataGridGettingStartedDotNET/MainWindow.xaml#L31

xml
<dxg:GridColumn FieldName="OrderId" IsSmart="True"/>
<dxg:GridColumn FieldName="CustomerId" IsSmart="True" SortIndex="1" SortOrder="Ascending"/>
<dxg:GridColumn FieldName="OrderDate" IsSmart="True" SortIndex="0" SortOrder="Descending"/>

wpf-data-grid-bind-to-custom-service-with-restrictions/CS/MainWindow.xaml#L16

xml
<dxg:GridControl.Columns>
    <dxg:GridColumn x:Name="hotColumn" FieldName="Hot" Visible="False" ShowInColumnChooser="False" AllowSorting="True" AllowedSortOrders="Descending" SortOrder="Descending" />
    <dxg:GridColumn x:Name="weekColumn" FieldName="Week" Visible="False" ShowInColumnChooser="False" AllowSorting="True" AllowedSortOrders="Descending" />

wpf-grid-prevent-expand-collapse-operations-for-group-rows/CS/Forbid_Expand_Collapse/MainWindow.xaml#L27

xml
<dxg:GridColumn FieldName="Discount"/>
<dxg:GridColumn FieldName="Status" GroupIndex="0" SortOrder="Descending"/>
<dxg:GridControl.View>

wpf-data-grid-customize-automatically-generated-columns/CS/E2019/Window1.xaml.cs#L19

csharp
column.CellTemplate = Application.Current.MainWindow.Resources["IssueNameTemplate"] as DataTemplate;
column.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
break;

wpf-data-grid-customize-automatically-generated-columns/VB/E2019/Window1.xaml.vb#L22

vb
column.CellTemplate = TryCast(Application.Current.MainWindow.Resources("IssueNameTemplate"), DataTemplate)
    column.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending
Case "IssueType"

See Also

ColumnBase Class

ColumnBase Members

DevExpress.Xpf.Grid Namespace