如何使用silverlight表单验证?

时间:2011-06-29 10:01:03

标签: silverlight

我需要创建一些客户注册表单,我需要检查表单中每行的验证。

最好的方法是什么? (我想使用正则表达式)

感谢。

1 个答案:

答案 0 :(得分:1)

我建议调查INotifyDataErrorInfo。您可以在客户端使用部分类并添加ComponentModel命名空间中提供的属性,也可以编写代码来引发这些事件。 WCF RIA服务在我看过的演示中使用了属性方法。 RIA Services实际上使用相同的属性在服务器和客户端上进行验证,它有好的和坏的点(在我看来)。

以下是我过去看过的一些有用的链接:

http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-binding-with-inotifydataerrorinfo.aspx(他有一个很好的开始创建一个基类来在一个地方处理大多数INotifyDataErrorInfo函数)

http://thejoyofcode.com/Silverlight_MVVM_and_Validation_Part_III.aspx
   http://channel9.msdn.com/learn/courses/Silverlight4/SL4BusinessModule3/SL4LOB_03_03_Validation/

http://weblogs.asp.net/fredriknormen/archive/2009/11/22/silverlight-4-and-asynchronous-validation-with-inotifydataerrorinfo.aspx