First, you can set the SelectionUnit="Cell"
, was selected to only one Cell
.
Second, you can start editing with key F2
.
To start editing when you click on a Cell
, you need to add the following event handler GotFocus
:
<DataGrid Name="MyDataGrid" SelectionUnit="Cell" GotFocus="MyDataGrid_GotFocus" ...>
Code behind
private void MyDataGrid_GotFocus(object sender, RoutedEventArgs e)
{
if (e.OriginalSource.GetType() == typeof(DataGridCell))
{
DataGrid MyDataGrid = (DataGrid)sender;
if ((MyDataGrid != null) && (MyDataGrid.IsReadOnly == false))
{
MyDataGrid.BeginEdit(e);
}
}
}