Yes ok. I understand.
The validation is a little bit complex.
My main problem is that I need to validate the whole chain from grandparent to childviewmodel if any property is changed in childviewmodel.
- Validation is not started in the parent and grandparentviewmodel if i change a property in childviewmodel
-> So I have a InterestedIn Attribut in grandparent if a property changed in childviewmodel I call Validate. And so Validation is started from top.
- In Parentviewmodel I need informations of childs to validate businessRules for overall validation. In Parentviewmodel there is no reference to childviewmodel.
(by design thats ok) But the model of the parentviewmodel has a reference to childmodel. So I can use the propertys of the childmodel for my validation. But:
The Propterty which have caused the validation has the old value in childmodel. So I have to start the validation 2 times.
The first validation is started from: see 1.
The second validation is started with the ChangeNotificationWrapper on the models:
private void SubscribePlacementValidation()
foreach (var wrapper in (
from station in Stations
from block in station.Locations
from place in block.Locations.Where(place => place is PlaceInstance)
select new ChangeNotificationWrapper(place)).Where(wrapper => wrapper != null))
wrapper.PropertyChanged += OnPropertyChanged;
private void OnPropertyChanged(object sender, PropertyChangedEventArgs eventArgs)
if (TagHelper.AreTagsEqual(eventArgs.PropertyName, "SelectedUnit") ||
And this is causing lots of more problems.
My Application is very complex. And its very difficult to make a repro to show the problems I have.
Maybe you can help me at least with one question: How to get the new value from child which is causing the validation. Without starting the validation seperate with