private void BomGrid_OnKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Down) { var currentRowIndex = (_viewModel.SelectedDetailRow.BomList.IndexOf(_viewModel.SelectedBomRow)); if (currentRowIndex == (_viewModel.SelectedDetailRow.BomList.Count - 1)) { _viewModel.AddBom(true); } } else if (e.Key == Key.Delete) { _viewModel.SelectedBomRows.Clear(); foreach (var row in BomGrid.SelectedItems) { _viewModel.SelectedBomRows.Add(row as BomViewModel); } _viewModel.DeleteBom(); } }