How to forward the data grid cell key down event's key to user control used as edit template?

Nov 11, 2010 at 10:18 AM

Hi, I have a WPF data grid and I am using a template column with different cell tamplate and cell editing template. I am handling KeyDown event on data grid cell to push it into edit mode when a key is pressed. The handler is as follows :

    void OnCellKeyDown (object inSender, KeyEventArgs inE) { 
        DataGridCell cell = inSender as DataGridCell; 
        if (inE.Key == Key.Up || inE.Key == Key.Down || inE.Key == Key.End || inE.Key == Key.Enter || 
            inE.Key == Key.Left || inE.Key == Key.Right || inE.Key == Key.Escape || inE.Key == Key.Return) { 
        else { 
            if (!cell.IsEditing) { 
                bool result = this.BeginEdit (new RoutedEventArgs (KeyDownEvent, inE)); 
        inE.Handled = false; 

The problem is, if user presses a key, I want cell to go in edit mode, clear its current value and set the value as pressed key instead. I am not able to do that.

I would like to get the pressed key in the load event of user control which is used as edit template.

Can somebody please help me

Nov 11, 2010 at 1:36 PM

I am sorry, but you are referring to a control that is in Microsoft's WPF Toolkit.  You can ask your question there.  I don't ever use the DataGrid so I am unable to help.  Just guessing, but if there was some kind of CellGotFocus or CellChanged event maye you could hanlde it there.