public MainWindowViewModel(MainWindow mainWindow) { statesUndo = new Stack<IMemento>(); statesRedo = new Stack<IMemento>(); commandBindings = mainWindow.CommandBindings; inkCanvas = mainWindow.InkCanvasWithUndo1; inkCanvas.MouseUp += InkCanvasWithUndo1_MouseUp; //Create a command binding for the save command var saveBindingUndo = new CommandBinding(ApplicationCommands.Undo, OnExecutedCommandsUndo); var saveBindingRedo = new CommandBinding(ApplicationCommands.Redo, OnExecutedCommandsRedo); //Register the binding to the class CommandManager.RegisterClassCommandBinding(typeof (MainWindowViewModel), saveBindingUndo); //Adds the binding to the CommandBindingCollection commandBindings.Add(saveBindingUndo); commandBindings.Add(saveBindingRedo); StoreState(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.window = ((Paint.MainWindow)(target)); return; case 2: this.InkCanvasWithUndo1 = ((Paint.InkCanvasWithUndo)(target)); return; } this._contentLoaded = true; }