private void MainGrid_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Down) { var currentRowIndex = (_viewModel.MainRowList.IndexOf(_viewModel.SelectedMainRow)); if (currentRowIndex == (_viewModel.MainRowList.Count - 1)) { _viewModel.AddNewMainRow(true); MainGrid.BeginEdit(); } } if (e.Key == Key.Delete && ModifierKeys.Shift == Keyboard.Modifiers) { _viewModel.SelectedMainRows.Clear(); foreach (var row in MainGrid.SelectedItems) { _viewModel.SelectedMainRows.Add((TblLedgerHeaderViewModel)row); } _viewModel.DeleteMainRow(); } else if (e.Key == Key.Enter) { e.Handled = true; } else if (e.Key == Key.Tab) { if (MainGrid.CurrentColumn != null) { int index = MainGrid.Columns.IndexOf(MainGrid.CurrentColumn); if (index == MainGrid.Columns.Count - 1) { var currentRowIndex = (_viewModel.MainRowList.IndexOf(_viewModel.SelectedMainRow)); if (currentRowIndex == (_viewModel.MainRowList.Count - 1)) { } } } } }