Wpf: how to handle KeyDown event for Datagrid?

I have a problem managing datagrid in wpf. when I press the enter button, I want to load the selected elements into a set of controls, but it seems that datagrid.KeyDown has already been processed, and it moves on to the next element.

I tried using keyup, but this event is fired when the datagrid keydown is triggered and the datagrid moves on to the next element.

any idea to handle keydown completely?

+6
source share
2 answers

Use the PreviewKeyDown event instead of KeyDown

+8
source

Perhaps KeyDown is being handled by ClassHandler.
Hearing listeners come after class listeners.

Good explanation of MSDN .

0
source

Source: https://habr.com/ru/post/893513/


All Articles