private static void AttachEventHandlers(TextBoxBase textBox, UndoManager manager) { if (textBox != null && manager != null) { textBox.AddHandler(CommandManager.PreviewExecutedEvent, new ExecutedRoutedEventHandler(manager.ExecutedHandler), true); // we need to see all events to subvert the built-in undo/redo tracking in the text boxes textBox.TextChanged += new TextChangedEventHandler(manager.TextChangedHandler); } }
public static void SetSharedUndoScope(DependencyObject obj, UndoManager value) { if (obj == null) { throw new ArgumentNullException("obj"); } obj.SetValue(SharedUndoScopeProperty, value); }
private static void RemoveEventHandlers(TextBoxBase textBox, UndoManager manager) { if (textBox != null && manager != null) { textBox.RemoveHandler(CommandManager.PreviewExecutedEvent, new ExecutedRoutedEventHandler(manager.ExecutedHandler)); textBox.TextChanged -= new TextChangedEventHandler(manager.TextChangedHandler); } }