简体   繁体   English

如何在ObservableCollection之后刷新绑定的GridView <T> 已排序?

[英]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.

相关问题 我如何排序一个ObservableCollection <T> 那绑定到一个ListBoxControl吗? - How can I sort an ObservableCollection<T> that's bound to a ListBoxControl? 如何通知完全依赖于ObservableCollection的绑定属性的更改? - How do I notify changes for a bound property that wholly depends on an ObservableCollection? 将数据插入表后,如何刷新GridView控件? - How do I refresh a GridView control after inserting data into the table? 删除绑定到GridView的ObservableCollection中的项目 - Delete Items in an ObservableCollection That are Bound to A GridView 更新绑定到它的ObservableCollection后,DataGrid不会更新 - DataGrid doesn't get updated after updating ObservableCollection that's bound to it 如何将工具提示数据绑定到绑定到DataTable的GridView? - How do I databind Tooltips to a GridView bound to a DataTable? 我如何获得绑定到ObservableCollection的UserControl派生类来响应添加? - How do I get a UserControl derived class thats bound to ObservableCollection to respond to adds? 如何存储ObservableCollection的集合 <T> 有不同类型的T? - How do I store a collection of ObservableCollection<T> with different types for T? 更改绑定的数据集后,如何刷新radSchedule? - How can I refresh a radSchedule after changes to a bound Dataset? 如何分页已绑定数据的gridview? - How to page gridview that already has data bound to it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM