IList のパラメーターを使用して CollectionChanged を呼び出すと、NotSuportedExceptionObservableCollection/ListCollectionView/CollectionView
が発生する理由について調べています。
//Throws an exception
private void collectionChanged_Removed(IList items)
{
if (CollectionChanged != null)
CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, items));
}
このトピックについて話しているいくつかのWebページを見つけました.UIをReset
完全に再描画する機能を使用するか、単に各アイテムを呼び出すCollectionChanged
か、より創造的な方法を提案しています: http://geekswithblogs.net/NewThingsILearned/ archive/2008/01/16/listcollectionviewcollectionview-doesnt-support-notifycollectionchanged-with-multiple-items.aspx
なぜ見つけられないのですか?私にとって、なぜこれが当てはまるのか意味がありません。
複数のアイテムをすばやく追加したい場合、 Add メソッドは多くのオーバーヘッドを必要とするため、開発サイクルのある時点で私たち全員が直面するこの不足している機能がいつでも実装される可能性はありますか (.Net 5 、C# 6...)。
編集:
私の特定のケースでは、私は自分のクラスを書きました:
public class ObservableList<T> : IList<T>, IList, IEnumerable<T>,
INotifyCollectionChanged
{
public event NotifyCollectionChangedEventHandler CollectionChanged;
//other stuff...
}
それでも、前述のNotSupportedExceptionをスローします。