Silverlight 数据表单验证不起作用
我无法获取数据表单,并且它是在验证时捕获异常的控件。
首先,我有:
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它实际上会导致应用程序崩溃,还是只是闯入 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!
好吧,显然 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.