-
Notifications
You must be signed in to change notification settings - Fork 1
Lazy Validation
Dmitry Shechtman edited this page Mar 26, 2017
·
3 revisions
-
Determine the type of the validation error (e.g.
string). -
Derive your view model from the corresponding
ValidatableBindableBase:using Ditto.AsyncMvvm; class UniversalAnswerViewModel : ValidatableBindableBase<string> { private int _answer; public int Answer { get { return _answer; } set { SetProperty(ref _answer, value); } } }
-
Override
GetErrorsOverride():protected override IEnumerable<string> GetErrorsOverride(string propertyName) { if (propertyName == "Answer") { if (Answer != 42) yield return "Answer is wrong."; } }
Done! However, a small optimization for WPF exists.