当我在datagrid的最后一个单元格上按下“TAB”键时,我希望能添加一行新记录。
我正在使用MVVM模式完成此操作。我已经想到了一个解决方案,将Tab键分配给datagrid的输入绑定:
<DataGrid.InputBindings>
<KeyBinding Command="{Binding Path=InsertNewLineCommand}" Key="Tab"></KeyBinding>
</DataGrid.InputBindings>
将以下代码添加到InsertNewLineCommand:
private void ExecuteInsertNewLineCommand()
{
//Checked is SelectedCell[0] at last cell of the datagrid
{
InsertNewLine();
}
}
但问题在于,如果我添加了KEYBINDING='TAB',那么我的表格的常规TAB功能将被禁用(无法移动到下一个单元格等)。