开发者

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:

  1. first-chance exceptions, and
  2. "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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜