答案 0 :(得分:1)
<强> CS 强>
实现CustomDataGrid,其中包含DataGrid
public class CustomDataGrid : DataGrid
{
protected override void OnPreparingCellForEdit(DataGridPreparingCellForEditEventArgs e)
{
base.OnPreparingCellForEdit(e);
var textbox = e.EditingElement as TextBox;
if (textbox == null) return;
textbox.Focus();
textbox.CaretIndex = textbox.Text.Length;
}
}
<强> XAML 强>
<CustomDataGrid>
</CustomDataGrid>