You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
David Sungaila edited this page Sep 18, 2020
·
1 revision
Let your class derive from PresentationBase.ViewModel. Create a backing field and make sure your property setter calls SetProperty.
Your function validates the given value and returns an IEnumerable<string> with found validation errors. Return null or an empty collection if the validation succeeds.
publicclassAwesomeViewModel:ViewModel{privatestring_name;publicstringName{get=>_name;set=>SetProperty(ref_name,value,NameValidation);}privateIEnumerable<string>NameValidation(stringvalue){if(string.IsNullOrEmpty(value))yieldreturn"Name cannot be null or empty!";elseif(value=="sungaila")yieldreturn"Name cannot be stupid!";}}