I'm using a custom ValidationRule to validate the data entered into a TextBox.
<TextBox> <Binding Path="Name" UpdateSourceTrigger="PropertyChanged"> <Binding.ValidationRules> <util:AlphanumericValidationRule/> <util:StringLengthIfEnteredRule Min="1"/> </Binding.ValidationRules> </Binding> </TextBox>
Which works fine to verify that only an alphanumeric string is entered, and it's length is greater than or equal to 1.
The issue is that the form this TextBox is a part of has a "Submit" button which is bound to a function inside of the DataContext. So when they hit submit I want to be able to be able to know whether or not all my fields are valid, inside the Data Context.
I've been looking into this for a little bit, and the best way I've see is to check if there any errors in the form in the Code-Behind file, and pass that information along to your DataContext. This solution is less than ideal, so I'm wondering if there's some sort of bindable property or something that I've missed that would provide this functionality?
tl;dr How do I tell my DataContext whether or not a field is validated using the XAML?