【发布时间】:2012-09-14 07:40:20
【问题描述】:
我是 WPF 的新手,我被一个我认为很容易解决的问题所困扰。 我有一个gridView(telerik one),它的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 列订购它,但无法得到它。
希望有人可以帮助我。 谢谢!
【问题讨论】:
-
看看 ICollectionView 和 SortDescriptions