WPF datavalidator execution stops for unhandledexception but hitting continue makes everything work?
In my code I have the following
if (String.IsNullOrEmpty(value))
{
throw new ApplicationException("You must enter a zip code!");
}
and
<TextBox.Text>
开发者_开发技巧 <Binding Path="ZipCode" Mode="TwoWay">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
When I execute and the code hits that exception, Visual Studio tells me that the Exception went unhandled by user code, but if I continue execution the desired WPF behavior (red outline around the textbox) occurs. Does anyone have insight into this and, namely, how to test my validator without getting this annoying error?
I think this is an unfortunate interaction between:
- first-chance exceptions, and
- "Just My Code"
Maybe it's just me but "Just My Code" isn't that useful because I always want to see all the code in stack traces, etc.! But it is nice for filtering and simplifying.
I believe that you'll have to turn off "Just My Code" in order to prevent "User-unhandled" exceptions like this because it's literally true that what Visual Studio considers "your code" isn't handling the exception.
精彩评论