title: WPF DataGridTemplateColumn. Am I missing something?
body: <pre><code>     &lt;data:DataGridTemplateColumn Header="Name"&gt;
          &lt;data:DataGridTemplateColumn.CellTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;TextBlock Text="{Binding Name}"&gt;
              &lt;/DataTemplate&gt;
          &lt;/data:DataGridTemplateColumn.CellTemplate&gt; 
          &lt;data:DataGridTemplateColumn.CellEditingTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;TextBox Text="{Binding Name}"&gt;
              &lt;/DataTemplate&gt;
          &lt;/data:DataGridTemplateColumn.CellEditingTemplate&gt; 
      &lt;/data:DataGridTemplateColumn&gt;              
  </code></pre>
  
  <p>It's clear example of Template column, right? What could be wrong with that? 
  So, here is the thing - when a user navigates through DataGrid with hitting TAB-key, it needs to hit the TAB twice(!) to be able to edit text in TextBox. How could I make it editable as soon as the user gets the column focus, I mean even if he just starts typing?</p>
  
  <p>Ok. I found a way - into Grid.KeyUp() I put the code below:</p>
  
  <pre><code> if (Grid.CurrentColumn.Header.ToString() == "UserName")
          {
              if (e.Key != Key.Escape) 
              {
                  Grid.BeginEdit();
  
                  // Simply send another TAB press
                  if (Keyboard.FocusedElement is Microsoft.Windows.Controls.DataGridCell)
                  {
                      var keyEvt = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Tab) { RoutedEvent = Keyboard.KeyDownEvent };
                      InputManager.Current.ProcessInput(keyEvt);
                  }
              }
          } 
  </code></pre>