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;
 }
}

Leave a Comment


NOTE - You can 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>