public static T GetCommandFromCommandButtons <T>(object sender) where T : CommandModelBase { CommandListingButtonsControl commandListingButtonsControl = (CommandListingButtonsControl)sender; if (commandListingButtonsControl != null && commandListingButtonsControl.DataContext != null) { if (commandListingButtonsControl.DataContext is CommandModelBase) { return((T)commandListingButtonsControl.DataContext); } else if (commandListingButtonsControl.DataContext is EventCommandItemViewModel) { EventCommandItemViewModel commandItem = (EventCommandItemViewModel)commandListingButtonsControl.DataContext; return((T)(CommandModelBase)commandItem.Command); } else if (commandListingButtonsControl.DataContext is StreamPassCustomLevelUpCommandViewModel) { StreamPassCustomLevelUpCommandViewModel commandItem = (StreamPassCustomLevelUpCommandViewModel)commandListingButtonsControl.DataContext; return((T)commandItem.Command); } else if (commandListingButtonsControl.DataContext is RedemptionStoreProductViewModel) { RedemptionStoreProductViewModel commandItem = (RedemptionStoreProductViewModel)commandListingButtonsControl.DataContext; return((T)commandItem.Command); } else if (commandListingButtonsControl.DataContext is GameOutcomeViewModel) { GameOutcomeViewModel commandItem = (GameOutcomeViewModel)commandListingButtonsControl.DataContext; return((T)(CommandModelBase)commandItem.Command); } } return(null); }
private void NewInteractiveCommandButton_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; EventCommandItemViewModel eventCommand = (EventCommandItemViewModel)button.DataContext; CommandWindow window = new CommandWindow(new EventCommandDetailsControl(eventCommand.EventType)); window.Closed += Window_Closed; window.Show(); }
public T GetCommandFromCommandButtons <T>(object sender) where T : CommandBase { CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender; if (commandButtonsControl.DataContext != null) { if (commandButtonsControl.DataContext is CommandBase) { return((T)commandButtonsControl.DataContext); } else if (commandButtonsControl.DataContext is EventCommandItemViewModel) { EventCommandItemViewModel commandItem = (EventCommandItemViewModel)commandButtonsControl.DataContext; return((T)((CommandBase)commandItem.Command)); } } return(null); }