Skip to content
Dmitry Shechtman edited this page Mar 26, 2017 · 1 revision
  1. Determine the type of the validation error (e.g. string).

  2. 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); }
        }
    }
  3. 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.

Clone this wiki locally