///-------------------------------------------------------------------------------- /// <summary>This method executes the delete item command.</summary> /// /// <param name="sender">Sender of the event.</param> /// <param name="e">Event arguments.</param> ///-------------------------------------------------------------------------------- protected void DeleteExecuted(object sender, ExecutedRoutedEventArgs e) { if (DataContext is IWorkspaceViewModel) { if (MessageBox.Show(DisplayValues.Message_DeleteItemConfirmation, DisplayValues.Message_DeleteItemConfirmationCaption, MessageBoxButton.OKCancel) == MessageBoxResult.OK) { PropertyCollectionItemViewModel context = DataContext as PropertyCollectionItemViewModel; if (context != null) { if (context.IsObjectInstanceListVisible == true && ObjectInstanceListItemsGrid.SelectedItem is PropertyInstanceViewModel) { context.AddToDeletedPropertyInstances(ObjectInstanceListItemsGrid.SelectedItem as PropertyInstanceViewModel); } else if (context.IsValueListVisible == true && ValueListItemsGrid.SelectedItem is PropertyInstanceViewModel) { context.AddToDeletedPropertyInstances(ValueListItemsGrid.SelectedItem as PropertyInstanceViewModel); } else if (context.IsValueVisible == true && ValueItemsGrid.SelectedItem is PropertyInstanceViewModel) { context.AddToDeletedPropertyInstances(ValueItemsGrid.SelectedItem as PropertyInstanceViewModel); } } } } }
///-------------------------------------------------------------------------------- /// <summary>This method determines if the delete command can execute.</summary> /// /// <param name="sender">Sender of the event.</param> /// <param name="e">Event arguments.</param> ///-------------------------------------------------------------------------------- protected void PreviewDeleteCanExecute(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = false; PropertyCollectionItemViewModel context = DataContext as PropertyCollectionItemViewModel; if (context != null) { if (context.IsObjectInstanceListVisible == true) { e.CanExecute = ObjectInstanceListItemsGrid.SelectedItem != null; } else if (context.IsValueListVisible == true) { e.CanExecute = ValueListItemsGrid.SelectedItem != null; } else if (context.IsValueVisible == true) { e.CanExecute = ValueItemsGrid.SelectedItem != null; } } e.Handled = true; }