0

I am trying to implement undo and redo to my application. To realize that stuff - I'm using the Monitored Undo Framework and MVVM light.

Here is some code (without CanExecute,..)

    public class ViewModel_Main : ViewModelBase, ISupportsUndo
        {
            public ViewModel_Main(IRaDataService dataService)
            {
                Networks = new ObservableCollection<ViewModel_Network>();
            }



private const string NetworksPropertyName = "Networks";
    private ObservableCollection<ViewModel_Network> _Networks;
    public ObservableCollection<ViewModel_Network> Networks
    {
        get
        {
            return _Networks;
        }
        set
        {
            _Networks = value;
            RaisePropertyChanged(NetworksPropertyName);
        }
    }

            private void AddNetworkCommand_Execute()
            {
                ViewModel_Network newNetwork = new ViewModel_Network("undefinded.RaNet", "x");
                DefaultChangeFactory.Current.OnChanging(this, NetworksPropertyName, Networks, newNetwork);
                Networks.Add(newNetwork);
            }

            private void UndoCommand_Execute()
            {
                UndoService.Current[this].Undo();
            }

            public object GetUndoRoot()
            {
                return this;
            }
    }

So let's get to my problem: the undo does not work.. but why?

Thank you!

MisterPresident
  • 563
  • 7
  • 20
  • *the undo does not work* is a terrible description of your problem. You'll have to make more effort than that in asking your question if you seriously want some help. – Sheridan Apr 29 '15 at 11:51
  • Did you attempt to debug this? What did you find? What did you examine? –  Apr 29 '15 at 12:46
  • Sorry for the bad explaination. I tried to debug - i think the problem might be that stored value of the framework changes because c# does not make a copy of a observable collection. – MisterPresident Apr 29 '15 at 13:36

0 Answers0