Example #1
0
        private void SearchBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Down)
            {
                MasterDataGrid.Focus();
                //then create a new cell info, with the item we wish to edit and the column number of the cell we want in edit mode
                var cellInfo = new DataGridCellInfo(MasterDataGrid.Items[0], MasterDataGrid.Columns[0]);
                //set the cell to be the active one
                MasterDataGrid.CurrentCell = cellInfo;
                //scroll the item into view
                MasterDataGrid.ScrollIntoView(MasterDataGrid.Items[0]);
                //begin the edit
                MasterDataGrid.BeginEdit();
            }

            if (e.Key == Key.Up)
            {
                MasterDataGrid.Focus();
                //then create a new cell info, with the item we wish to edit and the column number of the cell we want in edit mode
                var cellInfo = new DataGridCellInfo(MasterDataGrid.Items[MasterDataGrid.Items.Count - 1],
                                                    MasterDataGrid.Columns[0]);
                //set the cell to be the active one
                MasterDataGrid.CurrentCell = cellInfo;
                //scroll the item into view
                MasterDataGrid.ScrollIntoView(MasterDataGrid.Items[MasterDataGrid.Items.Count - 1]);
                //begin the edit
                MasterDataGrid.BeginEdit();
            }
        }
Example #2
0
        private void MainWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Oem3)
            {
                Application.Current.Shutdown();
            }
            if (e.Key == Key.Escape)
            {
                SearchBox.Focus();
                SearchBox.SelectAll();
            }

            if (e.Key == Key.Down || e.Key == Key.Up)
            {
                if (!MasterDataGrid.IsFocused)
                {
                    MasterDataGrid.Focus();
                }
            }
        }