[英]How do I refresh a bound GridView after the ObservableCollection<T> has be sorted?
The implementation is a for a Refresh button. 该实现是“刷新”按钮的。 I use .Clear() to empty the list, then add back in the latest data.
我使用.Clear()清空列表,然后重新添加最新数据。 After the data is loaded I use the following function to then sort the list:
加载数据后,我使用以下函数对列表进行排序:
public void SortByDate()
{
this.oCol = new ObservableCollection<OCol>(this.oCol.OrderByDescending(myDate => myDate));
}
The GridView refreshes with the information that I add into it, but when I run the SortByDate() function, the GridView does not refresh to reflect the new order. GridView会使用我添加到其中的信息进行刷新,但是当我运行SortByDate()函数时,GridView不会刷新以反映新的顺序。 What do I need to do differently?
我需要做些什么?
You need to raise a PropertyChanged
event for the property that is backed by oCol
. 您需要引发由
oCol
支持的属性的PropertyChanged
事件。 You have changed the collection and the framework is still databinding to the old collection. 您已经更改了集合,并且框架仍与旧集合进行数据绑定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.