wpf : how to handle KeyDown Event for Datagrid?

Pouyan picture Pouyan · Jul 25, 2011 · Viewed 10.3k times · Source

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 ?

Answer

Rachel picture Rachel · Jul 25, 2011

Use the PreviewKeyDown event instead of KeyDown