private void dgMain_PreviewKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (_viewModel.AllowNew) { _viewModel.NewWarehouseLocationBinCommand(""); //set the first visible column to allow for edit w/o requireing a click to select it... dgMain.CurrentCell = new DataGridCellInfo( dgMain.Items[dgMain.Items.Count - 1], dgMain.Columns[0]); dgMain.BeginEdit(); } else { MessageBox.Show("New WarehouseLocationBin Is Not Enabled...", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }