wpf-devexpress-dot-xpf-dot-grid-b55f143c.md
Represents a collection of GridSortInfo objects.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public class GridSortInfoCollection :
SortInfoCollectionBase
Public Class GridSortInfoCollection
Inherits SortInfoCollectionBase
The following members return GridSortInfoCollection objects:
This collection can be accessed via the GridControl.SortInfo property. It provides methods that allow you to perform common collection management tasks (add, remove or change required settings of individual elements). Adding new GridSortInfo objects to this collection applies sorting or grouping by specific columns. Similarly, removing elements from the collection clears sorting/grouping by the corresponding columns.
To learn more, see Sorting in Code.
This example shows how to apply data sorting and grouping in XAML.
Since group rows are always sorted, data grouping requires data sorting. Sorting applied to group columns takes priority over other columns. To group data by one column in XAML, do the following:
The image below shows the result:
using System.ComponentModel;
using DevExpress.Xpf.Grid;
public Window1() {
InitializeComponent();
grid.DataSource =
new dsNwindProductsTableAdapters.ProductsTableAdapter().GetData();
CreateSortInfo(grid);
}
private void CreateSortInfo(GridControl grid) {
grid.SortInfo.Add(new GridSortInfo("UnitPrice", ListSortDirection.Descending));
grid.SortInfo.Add(new GridSortInfo("ProductName", ListSortDirection.Ascending));
grid.GroupCount = 1;
}
<dxg:GridControl x:Name="grid" GroupCount="1">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="ProductName"/>
<dxg:GridColumn FieldName="UnitPrice"/>
<dxg:GridColumn FieldName="UnitsOnOrder" Header="Units On Order"/>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True" ShowGroupedColumns="False"/>
</dxg:GridControl.View>
<dxg:GridControl.SortInfo>
<dxg:GridSortInfo FieldName="UnitPrice" SortOrder="Descending"/>
<dxg:GridSortInfo FieldName="ProductName" SortOrder="Ascending"/>
</dxg:GridControl.SortInfo>
</dxg:GridControl>
Object Collection<GridSortInfo> ObservableCollection<GridSortInfo> DevExpress.Xpf.Core.ObservableCollectionCore<GridSortInfo> DevExpress.Xpf.Grid.SortInfoCollectionBase GridSortInfoCollection
See Also