Xceed DataGrid for WPF v7.3 Documentation
SortIndex Property
Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > ColumnBase Class : SortIndex Property
Gets the sort index of the column.
Syntax
'Declaration
 
Public ReadOnly Property SortIndex As Integer
 
'Usage
 
Dim instance As ColumnBase
Dim value As Integer
 
value = instance.SortIndex

Property Value

A value representing the sort index of the column. If -1, the column is not sorted. By default, -1.
Remarks
The sort index represents the order in which the column was sorted. For example, if 2 columns are sorted, the first one that was sorted will have its SortIndex property set to 0 while the second will have its SortIndex property set to 1. Columns which are not sorted will have their SortIndex property set to -1.
Example
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 sort the data items in an ascending direction according to the values of the ShipCountry column.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.The following code provides the implementation of the AddressComparer class.The following code provides the implementation of the AddressComparer class.
<Grid xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" 
      xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"> 
  <Grid.Resources> 
    <xcdg:DataGridCollectionViewSource x:Key="cvs_orders" 
                                     Source="{Binding Source={x:Static Application.Current}, 
                                                       Path=Orders}"> 
 
     <xcdg:DataGridCollectionViewSource.SortDescriptions> 
       <scm:SortDescription PropertyName="ShipCountry" Direction="Ascending"/> 
     </xcdg:DataGridCollectionViewSource.SortDescriptions> 
    </xcdg:DataGridCollectionViewSource>           
  </Grid.Resources> 
 
  <xcdg:DataGridControl x:Name="OrdersGrid" 
                        ItemsSource="{Binding Source={StaticResource cvs_orders}}"> 
    <xcdg:DataGridControl.Columns> 
      <xcdg:Column FieldName="ShipCountry" VisiblePosition="0"/> 
    </xcdg:DataGridControl.Columns> 
  </xcdg:DataGridControl> 
</Grid>
Requirements

Target Platforms: Windows 11, Windows, 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ColumnBase Class
ColumnBase Members