Hi
We have a large WPF MVVM application. As a main validation technique we chose INotifyDataErrorInfo, and fully implemented it.
Now we have a problem. I'm pretty sure that almost every on who use INotifyDataErrorInfo in WPF, Silverlight, WindowsPhone, (may be also WindowsStore) meet this problem.
The problem: when the View is just loaded (and before any typing in any textboxes), some tesxboxes already have validation errors (red frames). It occures because before the View is loaded, the ViewModel already have some validation errors as a result of some assigments in the ctor of the ViewModel. But we want the values in ViewModels to be validated only after the View is loaded.
Please note that "IDataErrorInfo" technique behaves the same mentioned problematic way.
Also note that "ValidationRules" technique doesn't behaves the mentioned problematic way. "ValidationRules" technique start validating after the screen is loaded and after the user start editing the textbox.
So my question is: what should be done in order to couse the View to start the validations only after the View loaded?
The next solution is not good: add some "ViewLoaded" boolean flag to the ViewModel, cause the View to set it to true after the View loaded, and when do the validations () in the ViewModel only when this "ViewLoaded" boolean flag is true.
This solution is not good because of several reasons:
1. Unitests.
2. some View is a part of some tab control that has 4 tab items. The problematic View can be a part of third tab item. We want the validations to start only after we switched to this tabitem (not exactly loaded).
Genarally, it is not a good approach to try to solve this problem through VieModels.
The right solution should be to disable it on the View level before the View loaded (or brough to view).
So what is the solution to the problem?