I have ObservableCollection collection, and I want to replace all elements with a new collection of elements, I could do:
collection.Cl
ColinE is right with all his informations. I only want to add my subclass of ObservableCollection that I use for this specific case.
public class SmartCollection : ObservableCollection {
public SmartCollection()
: base() {
}
public SmartCollection(IEnumerable collection)
: base(collection) {
}
public SmartCollection(List list)
: base(list) {
}
public void AddRange(IEnumerable range) {
foreach (var item in range) {
Items.Add(item);
}
this.OnPropertyChanged(new PropertyChangedEventArgs("Count"));
this.OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
public void Reset(IEnumerable range) {
this.Items.Clear();
AddRange(range);
}
}