How to remove wpf grid sort arrow after clearing sort descriptions
I came across this question whilst trying to work out how to clear the sort from the grid completely. Thanks to [krishnaaditya] for the answering how to clear the sort arrow from the header.
using System.Windows.Data;
using System.ComponentModel;
ICollectionView view = CollectionViewSource.GetDefaultView(resultsGrid.ItemsSource);
if (view != null && view.SortDescriptions.Count > 0)
{
view.SortDescriptions.Clear();
foreach (DataGridColumn column in resultsGrid.Columns)
{
column.SortDirection = null;
}
}
simple solution i can think of is
foreach (DataGridColumn column in DataGridView.Columns)
{
column.SortDirection = null;
}