public override void OnExecute(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { if (SelectionManager.SelectedShape != null) { if (SelectionManager.SelectedShape is Control) { Control ctrl = SelectionManager.SelectedShape as Control; ControlTemplate template = ctrl.Template; if (template != null) { TextBlock text = template.FindName("BodyText", ctrl) as TextBlock; if (text != null) { //doesn't make make much sense to accumulate the underline command in the undo stack... if (!text.TextDecorations.Contains(TextDecorations.Underline[0])) { //make it undoable MakeUnderlineCommand cmd = new MakeUnderlineCommand(text); UndoManager.Execute(cmd); } } } } } }