wpf : how to handle KeyDown Event for Datagrid?

2019-06-20 02:44发布

I have a problem with datagrid control in wpf . when I press enter I want to load selected items in a set of controls, but it seems that datagrid.KeyDown is already handled and it goes to the next item.

I tried using keyup but this event fires when the datagrid keydown had been fired and datagrid goes to the next item.

any idea to handle keydown completely ?

2条回答
干净又极端
2楼-- · 2019-06-20 02:55

Use the PreviewKeyDown event instead of KeyDown

查看更多
地球回转人心会变
3楼-- · 2019-06-20 03:15

Maybe KeyDown is handled by a ClassHandler.
Instance listeners come after class listeners.

A good explanation on MSDN.

查看更多
登录 后发表回答