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

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

Clone this wiki locally