撤消集合 - 受监视的撤消框架

时间:2015-04-29 10:09:59

标签: c# wpf mvvm undo redo

我正在尝试对我的应用程序实现撤消和重做。 要实现这些目标 - 我使用了Monitored Undo Framework和MVVM灯。

这是一些代码(没有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;
            }
    }

让我们来解决我的问题: 撤消不起作用..但为什么?

谢谢!

0 个答案:

没有答案