I have applied MVVM in my app to implement validation rules for some pages by following this tutorial and this sample so validations are working properly and it is very creative way but I have one issue while validating Textbox text in the following scenario:
After implementing Required
OR Regular Expression
or any other data validation rule, it won't work unless some changes happen to the Textbox text(i.e user enter some text and remove it, will trigger the REQUIRED validation and validation error will be there)
That means all TextBoxes in the page will be valid even if they are annotated by Required
and they don't include any text (in case there are no changes happened to their text yet)
According to the sample testing on my side, unless you invoke the following
ValidateProperties()
method which is for validate all the properties otherwise you will not got all validated.ViewModel
inherit fromValidatableBindableBase
class which will get anErrors
property. EveryTextBox
control bind its ownErrors
property. The error for oneTextBox
will update once this one property changed, which will not influence otherTextBox
since their properties don't change.Text updated lead the first
TextBox
validated but not the second one:Validated all: