SortDescriptions Property (DataGridCollectionViewBase)
Property Value
A
SortDescriptionCollection containing the
SortDescription objects that describe how the items in the collection are sorted in the view.
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" );
}
.NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.
.NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.