I have a WPF Datagrid and its integer datatype columns are editable and hence i want to add a keypress event so that when user starts to edit a cell and presses up arrow key the value in that cell increments by 1 and if down arrow key is presses it decrements by 1.
I think i have to do something like this but where and how?
DatagridCell.KeyPress += new ....... (....);
in the Xaml => hook a handler on the PreviewKeyDown event of your Grid.
And in the code as well you might either access your Grid with its ‘Name’ or find it with the VisualTreeHelper in your window, or…. and then hook an event handler on it.
You can then see if you are editing a cell in this grid, find wich one is edited looking into the grid ( GridName.SelectedCells ) or using the event parameters ( e.OriginalSource ) and act accordingly.