ColinE提供的所有信息都是正确的。我只想添加
ObservableCollection用于此特定情况的子类。
public class SmartCollection<T> : ObservableCollection<T> { public SmartCollection() : base() { } public SmartCollection(IEnumerable<T> collection) : base(collection) { } public SmartCollection(List<T> list) : base(list) { } public void AddRange(IEnumerable<T> 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<T> range) { this.Items.Clear(); AddRange(range); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)