1

I have a textbox:

<TextBox Text="{Binding SomeInt}" />

SomeInt is of type int and therefore when my view shows, if binded correctly it displays the value of SomeInt in my case 0.

If I enter "abc" on the textbox then the textbox shows a red border outside of it which is great. How can I detect that the textbox has a red border in order to prevent the user from submitting the form?.

BradleyDotNET
  • 59,038
  • 10
  • 94
  • 113
Tono Nam
  • 31,694
  • 75
  • 272
  • 444
  • 1
    FYI This is a *validation* error, not a binding one. Binding errors throw `System.Data` (some class I don't remember) exceptions. IIRC its OnDataError or something like that for validation errors. – BradleyDotNET Nov 26 '14 at 19:39
  • 2
    possible duplicate of [Detecting WPF Validation Errors](http://stackoverflow.com/questions/127477/detecting-wpf-validation-errors) – paparazzo Nov 26 '14 at 20:04
  • In MVVM you'd be doing validation in the VM and implement IDEI. In this case, I'd use a nullable int and report an error if the value was null. –  Nov 26 '14 at 21:02

0 Answers0