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