清除排序说明后如何删除wpf网格排序箭头

Joh*_*ohn 5 c# sorting wpf wpfdatagrid c#-4.0

我单击网格标题对列进行排序,然后单击"重置"按钮以通过其集合视图清除排序描述.但排序箭头图标仍然存在于标题中.如何删除它?

And*_*rea 7

我试图找出如何从网格中彻底清除排序时遇到了这个问题.感谢[krishnaaditya]回答如何清除标题中的排序箭头.

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;
                                 };
                             }
Run Code Online (Sandbox Code Playgroud)


小智 5

我能想到的简单解决方案是

foreach (DataGridColumn column in DataGridView.Columns)
{
    column.SortDirection = null;
}
Run Code Online (Sandbox Code Playgroud)