When I am in a grid, I want to capture some keys to do something. I capture the "delete" key and I have not problems, but when I try to capture the "Return" key and I am editing a cell, when I press the Return key I don't leave the edit cell mode.
If I don't do the keybinding of the Return, when I press the return while I am editing a cell, it leaves the edit mode and goes to the next row.
If I comment all the code of the "Return" keybinding, the problem occurs, so I think that the problem is not the code that I use, but is the input keybinding of the return key.
must I have some special considerations when I want to capture the return key?
I am using the following code in the xaml to make the binding:
<DataGrid.InputBindings>
<KeyBinding Key="Delete" Command="{Binding myCommand}"
CommandParameter="Delete"/>
<KeyBinding Key="Return" Command="{Binding myCommand}"
CommandParameter="Return"/>
</DataGrid.InputBindings>
</DataGrid.InputBindings>
Thanks.
You overwrite the existing input-binding to the CommitEditCommand
, you need to manually execute that command in your own if you want to retain the default behavior.
(You can use CommitEdit
for that, which invokes the command.)