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 italic command in the undo stack... if (!text.FontStyle.Equals(FontStyles.Italic)) { //make it undoable MakeItalicCommand cmd = new MakeItalicCommand(text); UndoManager.Execute(cmd); } } } } } }