title: "An ItemsControl is inconsistent with its items source" thrown when calling MessageBox.Show()
body: <p>I'm extremely new to WPF and I have the following problem:</p>
  
  <p>I'm trying to develop a practice application to help me have control of my budgets.</p>
  
  <p>I have a class Partida like so:</p>
  
  <pre><code>public class Partida
  {
      public delegate void PartidaChangedHandler(Partida p);
      public event PartidaChangedHandler OnPartidaChanged;
      private ObservableCollection&lt;PartidaEntry&gt; content;
  
      public Partida()
      {
          content = new ObservableCollection&lt;PartidaEntry&gt;();
          content.CollectionChanged += PartidaEntriesCollectionChanged;
  
      }
  
      public void PartidaEntriesCollectionChanged(object s, NotifyCollectionChangedEventArgs args)
      {
          if (OnPartidaChanged != null)
          {
              OnPartidaChanged(this);
          }
      }
  }
  </code></pre>
  
  <p>I'm displaying the <code>content</code> collection with a Datagrid, but I need to know when the <code>content</code> collection of this class changed and fire the <code>OnPartidaChanged</code> event.</p>
  
  <p>Outside of the class (in MainWindow) I hook up to the <code>OnPartidaChanged</code> event like so:</p>
  
  <pre><code>p.OnPartidaChanged += (Partida ppp) =&gt;
  {
      int foo = 5;
      MessageBox.Show("A partida has changed!");
  };
  </code></pre>
  
  <p>When I add a new row within the DataGrid, the event fires correctly, however as soon as MessageBox gets executed I get an <code>InvalidOperationException</code> with the following message: </p>
  
  <blockquote>
    <p>An ItemsControl is inconsistent with its items source.</p>
  </blockquote>
  
  <p>Any idea how can a fix that problem without losing the ability to listen to the ObservableCollection's CollectionChanged event and firing OnPartidaChanged after that event?</p>
  
  <p>Thanks in advance!</p>
  
  <p>P.S.: Also, I would like to know what on earth MessageBox has to do with ItemControl... why is the exception firing if MessageBox only displays a simple box! :S</p>