private void ExecuteCustomCommand(object sender, ExecutedRoutedEventArgs e) { if (sender == null) { return; } CommandingUCViewModel UCvm = e.Parameter as CommandingUCViewModel; MessageBox.Show(UCvm?.Title, "Custom Command Executed!"); _vm.UpdateLastPushedCmd.Execute(UCvm); }
// CanExecuteRoutedEventHandler that only returns true if // the source is a control. private void CanExecuteCustomCommand(object sender, CanExecuteRoutedEventArgs e) { Control target = e.Source as Control; CommandingUCViewModel UCvm = e.Parameter as CommandingUCViewModel; if (target != null && UCvm != null) { e.CanExecute = _vm.UpdateLastPushedCmd.CanExecute(UCvm); ; } else { e.CanExecute = false; } }