private void dgMain_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { if (_viewModel.AllowDelete) { _viewModel.DeleteWarehouseLocationCommand(); return; } //MessageBox.Show("Delete Is Not Enabled...", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }