Silverlight 数据表单验证不起作用

发布于 2024-08-27 23:52:16 字数 327 浏览 1 评论 0原文

我无法获取数据表单,并且它是在验证时捕获异常的控件。

首先,我有:

<PasswordBox Password="{Binding Password,Mode=TwoWay,NotifyOnValidationError=true,ValidatesOnExceptions=true}" />

所有必需的属性都设置为 true。

在我的密码属性的设置器中,我在验证失败时抛出 ValidationException,但数据表单没有捕获它,它只会导致应用程序崩溃,就好像它是正常异常一样。

我做错了什么吗? 谢谢

I can't get dataform and it's controls to catch exceptions when validating.

Fir instance, I have:

<PasswordBox Password="{Binding Password,Mode=TwoWay,NotifyOnValidationError=true,ValidatesOnExceptions=true}" />

All required properties are set to true.

In the setter of my Password property I throw a ValidationException upon failed validation, but the data form doesn't catch it, it just causes the application to crash as if it were a normal exception.

Am I doing something wrong?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清浅ˋ旧时光 2024-09-03 23:52:16

它实际上会导致应用程序崩溃,还是只是闯入 Visual Studio 中的调试器?

如果它只是闯入调试器,那么这是设计使然,实际上并没有破坏任何东西。您可以按 F5 继续,您的验证应该按预期进行。

但从长远来看,这可能会变得相当烦人。如果您愿意,可以告诉调试器忽略 Silverlight 验证异常,如下所述 此处

此处描述了另一种稍微不同的避免此问题的技术。

希望这有帮助!

Does it actually cause the application to crash, or does it just break into the debugger in Visual Studio?

If it simply breaks into the debugger, this is by design and nothing's actually broken. You can push F5 to continue, and your validation should work as expected.

In the long run though, this can get quite annoying. If you'd like, you can tell the debugger to ignore Silverlight Validation Exceptions as described here.

Another slightly different technique to avoid this issue is described here.

Hope this helps!

空心↖ 2024-09-03 23:52:16

好吧,显然 Visual Studio 处于某种奇怪的状态,导致崩溃。重新启动后,一切正常。验证就像宣传的那样进行。

Ok, apparently Visual Studio was in some strange state where it was causing things to crash. After a restart, everything works perfectly. Validation works just as advertised.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文