I need to know when a WPF Datagrid has been sorted by the user. Why is there no Sorted
event? I can only find a Sorting event.
I also investigated the CollectionView
and ListCollectionView
that is exposing the objects to the View, without any luck.
I am quite surprised as this should come out of the box. Any ideas?
datagrid has "Sorting" event, subscribe to it!
XAML:
.cs code:
I've taken an example from MSDN documentation and adjusted it to raise a Sorted event when the Sorting event is done.
Then you can use it either in codebehind.
or in XAML
You can still subscribe to the DataGrid Sorting Event:
but to make sure that your actions happen after the sorting is done use Dispatcher :
This way, there's no need of a custom Datagrid class.