为什么不的ObservableCollection支持批量修改? [英] Why does ObservableCollection not support bulk changes?

查看:648
本文介绍了为什么不的ObservableCollection支持批量修改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是像的AddRange RemoveRange引起的的ObservableCollection 配套业务的潜在问题?必须有一个原因,微软没有提供给他们,现在的ObservableCollection是如此频繁地与WPF使用。

What are the potential problems caused by an ObservableCollection supporting operations like AddRange or RemoveRange? There must be a reason why Microsoft didn't provide them, now that ObservableCollection is so frequently used with WPF.

您可以实现自己的集合,它支持批量操作和工具 INotifyCollectionChanged 。如果我绑定这样的控制,以一个ItemsControl会发生什么?

You could implement your own collection that supports bulk operations and implements INotifyCollectionChanged. What happens if I bind such a control to an ItemsControl?

有谁知道ItemsControls的不支持批量修改?

Does anyone know of ItemsControls that don't support bulk changes?

推荐答案

我不认为这是有什么潜在的缺点或问题,它只是它不存在。事实上,你会发现,大多数类型的System.Collections.Generic没有提供的AddRange功能无论是。

I don't think it's that there are any potential downsides or problems, it's just that it isn't there. In fact, you will find that most types in 'System.Collections.Generic' don't supply 'AddRange' functionality either.

同时,很多人创造了他们的ObservableCollection'的自己的版本,以提供所需的功能。 INotifyCollectionChanged包含足够的信息,其处理程序来记时的各类物品已经可能影响了这个原因。

Meanwhile, lots of people have created their own versions of 'ObservableCollection' to provide the functionality that you want. INotifyCollectionChanged contains enough information for its handlers to make note of when a range of items have been affected probably for this reason.

最后但并非最不重要的,如果你绑定的集合这些有范围类型的操作,你会发现,他们将与你的用户界面按预期工作。

Last but not least, if you bind a collection that has these 'Range' type operations you will find that they will work with your UI as you expect

这篇关于为什么不的ObservableCollection支持批量修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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