c# - Trouble implementing Undo/Redo in my MVVM based application -


i'm having trouble implementing kind of undo redo system in application. guidance on how need in case. have read memento pattern, seems used, can't figure out how implement it.

first of al, application built using mvvm, actions ui bound method returns icommand. here's example:

public icommand playsoundcommand {     { return new delegatecommand(playsound); } }  private void playsound() {     methods.playsound(soundpath, selectedsound); } 

so playsoundcommand bound ui control , executes change needs made data. delegatecommand looks this:

class delegatecommand : icommand {     private readonly action action;      public event eventhandler canexecutechanged;      public delegatecommand(action action_)     {         action = action_;     }      public void execute(object parameter)     {         action();     }      public bool canexecute(object parameter)     {         return true;     }      public void raisecanexecutechanged()     {         if (canexecutechanged != null)         {             canexecutechanged(this, eventargs.empty);         }     } } 

when done, whichever method called using ui thing. there example method called addgroup() add group, obviously, observablecollection<groupmodelview> holds groups. collection declared this:

private observablecollection<groupviewmodel> groupmodellist = new observablecollection<groupviewmodel>(); public observablecollection<groupviewmodel> groupmodellist {     { return groupmodellist; }     set     {         groupmodellist = value;         onpropertychanged("groupmodellist");     } } 

inside groupmodel there viewmodel of object type holds list belongs group. (it holds other properties simple strings , floats)

how go implementing undo/redo system this?

if need more code, let me know. in advance!


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -