我是 WPF 的新手,我被一个我认为很容易解决的事情困住了。我有一个 gridView(telerik 之一),它的 ItemsSource 是一个 ObservableCollection,一切正常,当数据被修改时,我可以在网格中看到,当删除或添加某些内容时,网格被刷新。我的问题是,当集合更改时,更改的行转到网格中的最后一行,我需要对其重新排序,我尝试添加一个 SortDescriptor 以在更改集合时对网格进行排序,但没有任何反应。
//This update changes function is the one that changes the collection
updateChanges(field, new_value);
//This is the sortDescriptor that is supposed to order the grid
UIGlobal.MainPage.gridAnalog.SortDescriptors.Add(new SortDescriptor()
{
Member = "ColName",
SortDirection = System.ComponentModel.ListSortDirection.Ascending
});
这是我的网格
<telerik:RadGridView>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn UniqueName="ColName" Header="Name" DataMemberBinding="{Binding Key}"/>
<telerik:GirdViewDataColumn Header="Value" DataMemberBinding="{Binding Value}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
我想从 ColName 列订购它,但无法得到它。
希望有人能帮助我。谢谢!