在我的 WPF 应用程序中,我有DataGrid
一些列显示我的可排序数据。用户可以对他想要的任何列进行排序和子排序。
我添加了一个按钮,该按钮应该DataGrid
使用 MVVM 模式清除排序并将其返回到未排序状态(这意味着该按钮绑定到RelayCommand
ViewModel 中的 a,这将清除 DataGrid 的数据源的SortDescriptions
.)
这是代码现在的样子:
ViewModelLocator.MyViewModel.GroupedItems.SortDescriptions.Clear();
DataGridDataSource
是GroupedItems
对象(类型为ListCollectionView
)。当我单击该按钮时,我看到 DataGrid 返回到其原始的未排序状态,但是,列标题中的排序箭头保持不变,就好像 DataGrid 仍在排序一样。如何以编程方式删除这些箭头?