Validate

Topics: Questions
Nov 14, 2014 at 11:31 AM
Hi

I try to trigger a validation OnViewModelPropertyChanged
protected override void OnViewModelPropertyChanged(IViewModel viewModel, string propertyName)
        {
            base.OnViewModelPropertyChanged(viewModel, propertyName);

            if (viewModel is PlaceViewModel)
            {
                if (TagHelper.AreTagsEqual(propertyName, "SelectedUnit"))
                {
                    Validate(true);
                }
            }
        }
My problem: In nested viewmodel I ask the value of SelectedUnit from model. But the SelectedUnit has the the old value.

The value in viewmodel changed immidiately but the value in model is changed later.

How to get the new value in ValidateBusinesRules?
Nov 17, 2014 at 8:48 AM
Maybe its possible to add an InterestedIn on Model instead of Viewmodel?
Nov 17, 2014 at 9:05 AM
Ok. I think the notification wrapper is my solution

https://catelproject.atlassian.net/wiki/display/CTL/Change+notification+wrapper.
Nov 19, 2014 at 9:26 AM
The problem is:

First the Property in viewmodel starts the validation and after I have to start the validation again if the property is changed in the model.
Coordinator
Nov 19, 2014 at 9:41 AM
If you map them using [Model] and [ViewModelToModel], Catel will automatically take care of this for you.