MarkInvalid validation textbox using MVVM
I have a textbox that has a validation on it, in validation, it checks if its isNullOrEmpty. Validation works, but I am having difficulty if the user never selects the text box and clicks, I want the validation to run again. I was able to accomplish this in the XAML.cs file using:
Validation.MarkInvalid(cb.GetBindingExpression(dp), validationError);
Now with MVVM I am confused how can I do this from the viewmodel.
Text field in subject:
<TextBox>
<TextBox.Text>
<Binding Path="LastName">
<Binding.ValidationRules>
<validationRules:IsNullOrEmptyValidationRule/>
</Binding.ValidationRules>
<Binding.UpdateSourceTrigger>PropertyChanged</Binding.UpdateSourceTrigger>
<Binding.Mode>TwoWay</Binding.Mode>
</Binding>
</TextBox.Text>
</TextBox>
Any ideas?
+3
source to share
No one has answered this question yet
See similar questions:
or similar: