Xceed DataGrid for WPF v7.3 Documentation
Xceed.Wpf.DataGrid Assembly / Xceed.Wpf.DataGrid Namespace / DataGridCollectionViewBase Class / SortDescriptions Property
Example


In This Topic
    SortDescriptions Property (DataGridCollectionViewBase)
    In This Topic
    Gets a collection of SortDescription objects that describe how the items in the collection are sorted in the view.
    Syntax
    'Declaration
     
    Public Overrides ReadOnly Property SortDescriptions As SortDescriptionCollection
    'Usage
     
    Dim instance As DataGridCollectionViewBase
    Dim value As SortDescriptionCollection
     
    value = instance.SortDescriptions
    public override SortDescriptionCollection SortDescriptions {get;}

    Property Value

    A SortDescriptionCollection containing the SortDescription objects that describe how the items in the collection are sorted in the view.
    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 subscribe to the CollectionChanged event of the DataGridCollectionView.SortDescriptions collection's INotifyCollectionChanged interface implementation to be notified when sorting applied to a grid's columns changes.The following example demonstrates how to subscribe to the CollectionChanged event of the DataGridCollectionView.SortDescriptions collection's INotifyCollectionChanged interface implementation to be notified when sorting applied to a grid's columns changes.
    Protected Overrides Sub OnInitialized(ByVal e As EventArgs)
      MyBase.OnInitialized(e)
    
    
      Dim view As DataGridCollectionView = TryCast(Me.OrdersGrid.ItemsSource, DataGridCollectionView)
      AddHandler (CType(view.SortDescriptions, INotifyCollectionChanged)).CollectionChanged,
                                               AddressOf SortCollectionChanged
    End Sub
    Private Sub SortCollectionChanged(ByVal sender As Object, ByVal e As NotifyCollectionChangedEventArgs)
      Debug.WriteLine("Sort changed")
    
    End Sub
    protected override void OnInitialized( EventArgs e )
    {
     base.OnInitialized( e );
     DataGridCollectionView view = this.OrdersGrid.ItemsSource as DataGridCollectionView;
    
     ( ( INotifyCollectionChanged )view.SortDescriptions ).CollectionChanged +=
                                         new NotifyCollectionChangedEventHandler( this.SortCollectionChanged );
    }
    private void SortCollectionChanged( object sender, NotifyCollectionChangedEventArgs e )
    {
     Debug.WriteLine( "Sort changed" );
    }
    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