ObservableCollection 之批次更新

1 · Helix · Dec. 12, 2022, 2:13 p.m.
# 使用示例using (collection.BatchUpdate()){ collection.Add(...); ... // Some Addition collection.Remove(...); ... // Some Removal}// And then only one time OnCollectionChanged trigged.# 实现代码public class BulkObservableCollection<T> : ObservableCollection<T>{ protected bool _suppressNotification = false; protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { if (!_suppressNotification) base.OnCollectionChanged(e); } public IDispos...