title: Am I able to get the current value of the data grid cell during the KeyDown event
body: <p>I have event in data grid KeyDown. But I cant current value from updated cell. I need know value for every char changed.</p>
  
  <pre><code>if (DataGrid1.SelectedIndex == -1 || e.Key == Key.Enter || e.Key == Key.Tab || e.Key == Key.Escape)
      return;
  var thisValueIsNull = DataGrid1.CurrentCell.Item as Person;
  var thisValueIsBeforeStartUpdate = DataGrid1.SelectedItem as Person;
  </code></pre>
  
  <p>What should I do to get this value?</p>
  
  <p>Code xmal:</p>
  
  <pre><code>&lt;DataGrid x:Name="DataGrid1" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                AutoGenerateColumns="False" Grid.RowSpan="2" CanUserAddRows="False" LayoutUpdated="DataGrid1_LayoutUpdated" RowHeaderWidth="0" KeyDown="DataGrid1_KeyDown"&gt;
          &lt;DataGrid.Columns&gt;
  
              &lt;DataGridTextColumn x:Name="column1" Header="Name" Binding="{Binding Name}" Width="*"/&gt;
              &lt;DataGridTextColumn x:Name="column2" Header="SecondName" Binding="{Binding SecondName}" Width="*"/&gt;
              &lt;DataGridTextColumn x:Name="column3" Header="Age" Binding="{Binding Age}" Width="*"/&gt;
              &lt;DataGridTextColumn x:Name="column4" Header="Country" Binding="{Binding Country}" Width="*"/&gt;
              &lt;DataGridTextColumn x:Name="column5" Header="City" Binding="{Binding City}" Width="*"/&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Edit:</p>
  
  <pre><code> public partial class MainWindow : Window
  {
      List&lt;Person&gt; person = new List&lt;Person&gt;();
      public MainWindow()
      {
          InitializeComponent();
          person.Add(new Person() { Name = "Abb", SecondName = "AA" });
          person.Add(new Person() { Name = "Bbb", SecondName = "BB" });
          person.Add(new Person() { Name = "Ccc", SecondName = "CC" });
          DataGrid1.ItemsSource = person;
      }
  
      private void WordsDataGrid_KeyDown(object sender, KeyEventArgs e)
      {
  
      }
  }
  public class Person
  {
      public string Name { get; set; }
      public string SecondName { get; set; }
      public int Age { get; set; }
  
  }
  </code></pre>
  
  <p>Xaml:</p>
  
  <pre><code>&lt;DataGrid x:Name="DataGrid1" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                AutoGenerateColumns="False" Grid.RowSpan="2" CanUserAddRows="False" RowHeaderWidth="0" KeyDown="WordsDataGrid_KeyDown"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn x:Name="column1" Header="Name" Binding="{Binding Name}" Width="*"/&gt;
          &lt;DataGridTextColumn x:Name="column2" Header="SecondName" Binding="{Binding SecondName}" Width="*"/&gt;
              &lt;DataGridTextColumn x:Name="column3" Header="Age" Binding="{Binding Age}" Width="*"/&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  </code></pre>
  
  <p>In edit you have code this can you add to your program. It can be other event which let me take current value after every changed without click enter or changed focus.</p>
  
  <p>Solution:</p>
  
  <pre><code> &lt;DataGridTemplateColumn&gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;TextBlock Text="{Binding Name}"&gt;&lt;/TextBlock&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;TextBox Text="{Binding Name}" KeyUp="TextBox_KeyUp"&gt;&lt;/TextBox&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
  </code></pre>