wpf : how to handle KeyDown Event for Datagrid?

两盒软妹~` 提交于 2019-12-08 21:48:06

问题


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 ?


回答1:


Use the PreviewKeyDown event instead of KeyDown




回答2:


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

A good explanation on MSDN.



来源:https://stackoverflow.com/questions/6820266/wpf-how-to-handle-keydown-event-for-datagrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!