CollectionView.DeferRefresh()抛出异常 [英] CollectionView.DeferRefresh() throws exception

查看:490
本文介绍了CollectionView.DeferRefresh()抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有情况下,当你有到期的INotifyChangedProperties事件的巨量许多UI更新。在这种情况下,你可能想,只有当所有的属性都设置像一个批处理一旦信号更改UI。

There are cases when you have many UI updates due a massive amount of INotifyChangedProperties events. In that case you might want to signal the changes to UI only once when all the properties are set like in a batch.

我发现这篇大文章,介绍如何推迟该ViewCollection的刷新:

I found this great article that explains how to defer the refresh of the ViewCollection:

HTTP: //marlongrech.wordpress.com/2008/11/22/icollectionview-explained/

不过,我得到一个异常视图时延迟执行,我尝试添加东西德集合。我不明白为什么这不应该被允许。 。这就是它排在首位的整点

However I get an exception when the View is defered and I try to add something to teh collection. I dont understand why this shouldnt be allowed. Thats the whole point of it in first place.

出现InvalidOperationException:
不能更改或检查内容或刷新时被推迟
的CollectionView的当前位置。

InvalidoperationException: Cannot change or check the contents or Current position of CollectionView while Refresh is being deferred.

有谁知道如何解决这个问题?
非常感谢,

Does anyone know how to solve this problem? Many Thanks,

推荐答案

是,不修改有问题的集合。我认为你是误解集合视图的目的。这是MSDN说;

Yes, don't modify the collection in question. I think that you are misunderstanding the purpose of a collection view. This is what MSDN says;

您可以把一个集合视图
A层上的绑定源$ B $的顶部b集合,它允许您根据
排序,筛选,和组查询,所有
导航
,并显示集合,而无需操纵
源集合本身根本

You can think of a collection view as a layer on top of a binding source collection that allows you to navigate and display the collection based on sort, filter, and group queries, all without having to manipulate the underlying source collection itself.

因此,在短期,直到完成添加和删除,否则您的操作不会推迟刷新集合。

So in short, don't defer the refresh until you are done adding and removing, and otherwise manipulating your collection.

这篇关于CollectionView.DeferRefresh()抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆