Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
5124
Excel-like pressing Enter to edit the cell below
posted

Here is a way that you can implement one Excel-like behavior; entering edit mode in the cell below the active cell by pressing Enter. This can be done by handling the PreviewKeyDown event as follows:

 

        void XamDataGrid1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                XamDataGrid grid = (XamDataGrid)sender;
                if (grid.ActiveCell != null)
                {
                    this.XamDataGrid1.ExecuteCommand(DataPresenterCommands.CellBelow);
                    this.XamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);
                    e.Handled = true;
                }
            }
        }