using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; namespace Xamarin.PropertyEditing { internal class ObservableCollectionEx : ObservableCollection { public ObservableCollectionEx() { } public ObservableCollectionEx (IEnumerable collection) : base (collection) { } public void AddRange (IEnumerable range) { if (range == null) throw new ArgumentNullException (nameof(range)); foreach (T element in range) Add (element); return; //int index = Count; //var list = range.ToList (); //for (int i = 0; i < list.Count; i++) { // Items.Add (list[i]); //} //OnCollectionChanged (new NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction.Add, list, index)); } public void RemoveRange (IEnumerable range) { foreach (T element in range) Remove (element); } public void Reset (IEnumerable newContents) { if (newContents == null) throw new ArgumentNullException (nameof(newContents)); Items.Clear(); Items.AddItems (newContents); OnCollectionChanged (new NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction.Reset)); } } }