title: WPF DataGrid cell value changed event
body: <p>I have a setup that looks like this:</p>
  
  <pre><code>// myDG is a DataGrid whose columns are DataGridTextColumn
  ObservableCollection&lt;MyItem&gt; myOC;
  // myOC is populated with some new MyItem
  myDG.ItemsSource = myOC;
  </code></pre>
  
  <p>where <code>MyItem</code> implements <code>INotifyPropertyChanged</code>. What's the way to properly catch when the <em>user</em> inputs a value into a cell? </p>
  
  <p>I've tried catching <code>PropertyChanged</code> on the <code>MyItem</code>s, but I also update the values periodically in the background (the idea is that when the user manually edits the value, a flag is triggered that tells the periodic calculation to avoid overwriting the manually entered data). So <code>PropertyChanged</code> catches everything, including the periodic updates, which I don't want. I suppose it's possible to make this work (by setting a flag when I do the periodic calculation, then checking for absence of flag on the PropertyChanged event handler -- but I want to know if there's a simpler solution.)</p>
  
  <p>I've tried catching <code>myDG.CurrentCellChanged</code> but that's triggered every time the user changes the cell selection, not specifically when they edit cell contents.</p>
  
  <p>Edit: Here is the XAML:</p>
  
  <pre><code>&lt;DataGrid x:Name="myDG" ItemsSource="{Binding}" AutoGenerateColumns="False" Margin="10,10,182,0" VerticalAlignment="Top" Height="329" ClipboardCopyMode="IncludeHeader"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn Header="Col1" Binding="{Binding Prop1}" IsReadOnly="True"/&gt;
          &lt;DataGridTextColumn Header="Col2" Binding="{Binding Prop2}" IsReadOnly="False"/&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Here is the <code>MyItem</code> implementation (uses <a href="https://github.com/Fody/PropertyChanged" rel="noreferrer">Fody/PropertyChanged</a>):</p>
  
  <pre><code>[ImplementPropertyChanged]
  class MyItem : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
  
      public string Prop1 { get; set; }
      public string Prop2 { get; set; }
  
      public MyItem()
      {
          Prop1 = Prop2 = "";
      }
  }
  </code></pre>