I'm using Catel MVVM with WPF. I have a ViewModel using a Model which is decorated using the [Model] attribute. The Model inherits from ModelBase.
public class PartEditViewModel : ViewModelBase
{
[Model]
[Expose("Number")]
[Expose("Description")]
public Part Part{ get; set; }
...
TextBoxes are bound to the exposed properties to edit them. I'd like to have a button to reset changes to this model. I've tried calling CancelAsync which fires OnDeserializing of this Model, but the properties in the ViewModel are not updated to their original value.
How can I achieve the desired behaviour?
EDIT
I've tried to use ResetModel(nameof(Part), ModelCleanUpMode.CancelEdit); but it has no effect.
I noticed that PropertyChanged is not called on the instance of Part but only on the ViewModel.
Maybe this is due to the use of Expose fody weaving. My guess is, that the change of the property is not registered and therefore can't be reset.
ResetModel(nameof(Part))should do the trick.For implementation details, see https://github.com/catel/catel/blob/develop/src/Catel.MVVM/MVVM/ViewModels/ViewModelBase.cs#L1093