Couple of methods missing on ObservableCollection

Here are a couple of methods that are missing on ObservableCollection<T>:

public static class ObservableCollectionExtensions
{
 public static void AddRange<T>(this ObservableCollection<T> observableCollection, IEnumerable<T> elements)
 {
  foreach (var element in elements) observableCollection.Add(element);
 }

 public static ObservableCollection<T> Create<T>(IEnumerable<T> elements)
 {
  var observableCollection = new ObservableCollection<T>();
  observableCollection.AddRange(elements);
  return observableCollection;
 }
}

This entry was posted on Friday, November 6th, 2009 at 16:42 and is filed under C#, Silverlight, WPF. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply