【发布时间】:2013-08-29 14:02:01
【问题描述】:
我在 ViewModel 中使用ListCollectionView 来表示我的数据。我正在使用ListCollectionView 的SortDescriptions 进行数据库查询。我想在排序发生变化时通知 ViewModel 重新加载数据。
目前我正在使用 ListCollectionView.SortDescriptions 的 CollectionChanged 事件:
(EnitityView.SortDescriptions as INotifyCollectionChanged).CollectionChanged +=
(sender, args) =>
{
Task.Run(() => ReloadSort());
};
但是当我对多个列进行排序时,每列都会调用它,并且会开始多次加载。
是否有可能向ListCollectionView 或DataGrid 添加类似Sorted 事件的内容(如果可能添加类似附加行为的内容,我不喜欢控制继承这样的小事)? DataGrid 的排序事件不适用于我的目的,因为 SortDescriptions 在被调用时尚未更新。
【问题讨论】: