title: Can I somehow temporarily disable WPF data binding changes?
body: <p>I have a WPF application that uses MVVM data bindings. I am adding items to an <code>ObservableCollection&lt;...&gt;</code> and quite many of them indeed.</p>
  
  <p>Now I am wondering that every time I add one to the collection, does it instantly fire the event and cause unnecessary overhead? If so, can I somehow temporarily disable the event notifications and manually fire it once at the end of my code so that if I add 10k items, it gets only fired once, rather than 10k times?</p>
  
  <p>Update: I tried having this class:</p>
  
  <pre><code>using System;
  using System.Linq;
  using System.Collections.Specialized;
  using System.Collections.Generic;
  
  namespace MyProject
  {
  
      /// &lt;summary&gt; 
      /// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed. 
      /// &lt;/summary&gt; 
      /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt; 
      public class ObservableCollection&lt;T&gt; : System.Collections.ObjectModel.ObservableCollection&lt;T&gt;
      {
  
          /// &lt;summary&gt; 
          /// Adds the elements of the specified collection to the end of the ObservableCollection(Of T). 
          /// &lt;/summary&gt; 
          public void AddRange(IEnumerable&lt;T&gt; collection)
          {
              foreach (var i in collection) Items.Add(i);
              OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, collection.ToList()));
          }
  
          /// &lt;summary&gt; 
          /// Removes the first occurence of each item in the specified collection from ObservableCollection(Of T). 
          /// &lt;/summary&gt; 
          public void RemoveRange(IEnumerable&lt;T&gt; collection)
          {
              foreach (var i in collection) Items.Remove(i);
              OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, collection.ToList()));
          }
  
          /// &lt;summary&gt; 
          /// Clears the current collection and replaces it with the specified item. 
          /// &lt;/summary&gt; 
          public void Replace(T item)
          {
              ReplaceRange(new T[] { item });
          }
          /// &lt;summary&gt; 
          /// Clears the current collection and replaces it with the specified collection. 
          /// &lt;/summary&gt; 
          public void ReplaceRange(IEnumerable&lt;T&gt; collection)
          {
              List&lt;T&gt; old = new List&lt;T&gt;(Items);
              Items.Clear();
              foreach (var i in collection) Items.Add(i);
              OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, collection.ToList()));
          }
  
          /// &lt;summary&gt; 
          /// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class. 
          /// &lt;/summary&gt; 
          public ObservableCollection() : base() { }
  
          /// &lt;summary&gt; 
          /// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class that contains elements copied from the specified collection. 
          /// &lt;/summary&gt; 
          /// &lt;param name="collection"&gt;collection: The collection from which the elements are copied.&lt;/param&gt; 
          /// &lt;exception cref="System.ArgumentNullException"&gt;The collection parameter cannot be null.&lt;/exception&gt; 
          public ObservableCollection(IEnumerable&lt;T&gt; collection) : base(collection) { }
      }
  }
  </code></pre>
  
  <p>I get this error now:</p>
  
  <blockquote>
    <p>Additional information: Range actions are not supported.</p>
  </blockquote>
  
  <p>The error comes here:</p>
  
  <pre><code>OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, collection.ToList()));
  </code></pre>