Skip to main content

Posts

Showing posts from November, 2010

ObservableCollection AddRange

Damon Payne has a post AddRange for ObservableCollection in Silverlight 3 . It is pretty short and sweet way to improve performance when batch adding data to an ObservableCollection. He created a SmartCollection: [csharp] public class SmartCollection<T> : ObservableCollection<T> { public SmartCollection() { _suspendCollectionChangeNotification = false; } bool _suspendCollectionChangeNotification; protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { if (!_suspendCollectionChangeNotification) { base.OnCollectionChanged(e); } } public void SuspendCollectionChangeNotification() { _suspendCollectionChangeNotification = true; } public void ResumeCollectionChangeNotification() { _suspendCollectionChangeNotification = false; } public void AddRange