I'm having a little problem understanding how to do some validation on my model.
It is mostly regarding to cross-field / entity validation.
I will try to explane with a little example. (I'm working in SL/WPF)
I have a view that is linked to a viewmodel (Inherits from ViewModelBase).
In the view model i have a property of the type Input (Inherits from ModelBase).
In the Input object i have 2 properties DateFrom and DateTo (both DateTime).
So on the view i have 2 date selectors and a button.
The goal is to check on the button click if the DateTo is bigger then then DateFrom.
If i try to do this with the CustomValidation and ValidateProperty<DateTime> on my DateFrom and my DateTo then i keep getting errors while changing the properties. What is normal behavour as on that moment the combination of values is wrong, but the person
is still editing the form
I can place the CustomValidation attribute on my class itself but then i dont think it every gets called.
I think what is missing is a implementation of Validator.TryValidateObject in the ModelBase.
Is that correct or is there something i'm missing or doing wrong?