1

In my viewmodel, there is a property CurrentObject of the type SomeDomainType which is serializeable.

There is a form to edit its properties, and one of the buttons is "Commit Changes", databound to the ICommand CommitChangesCommand.

Now I expect this button to be active (via CanCommitChangesCommand(), properly wired with Josh Smith's RelayCommand) only when the object has been modified, that is, the object is "dirty".

Saying it again, what I want to ask is:

"How can I mark an object as dirty so that I could have a private bool ThatPropertyIsDirty() method to check that inside some CanExecute()?"

4

1 回答 1

1

从它的声音:

  1. IsDirty属性添加到您的SomeDomainType
  2. IsDirtyraiseNotifyPropertyChanged事件的 setter 中IsDirty
  3. SomeDomainType您更改以使考虑的对象的所有属性中Dirty,在它们的设置器中,设置IsDirty为 true

这是假设您SomeDomainType实现了INotifyPropertyChanged接口。如果没有,请围绕SomeDomainType它创建一个包装器类,并对该包装器进行上述更改。

于 2013-10-10T19:14:23.017 回答