add rangeコマンドを送信し、observablecolletionをリストビューにバインドする上記の実装のいずれかを使用すると、この厄介なエラーが発生します。
NotSupportedException
System.Windows.Data.ListCollectionView.ValidateCollectionChangedEventArgs(NotifyCollectionChangedEventArgs e)で
System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)で
System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(オブジェクト送信者、NotifyCollectionChangedEventArgs e)で
System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)で
私が行った実装では、WPFフレームワークの周囲でより均等に実装されているResetイベントを使用しています。
public void AddRange(IEnumerable<T> collection)
{
foreach (var i in collection) Items.Add(i);
OnPropertyChanged("Count");
OnPropertyChanged("Item[]");
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}