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 in C#, Silverlight, WPF. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>