I have a datagrid in WPF with a DataGridTextColum and a DataGridTemplateColum.
This approach works for me. It uses the fact that the DataGrid
will always create a new instance of the template when the editing starts:
and in the code behind:
private void TextBox_Loaded(object sender, RoutedEventArgs e)
{
((TextBox)sender).Focus();
((TextBox)sender).SelectAll();
}
As an added bonus, it also selects all text in the cell. It should work no matter how you enter the editing mode (double click, single click, pressing F2)