Silverlight best practice for validation?

走远了吗. 提交于 2019-12-25 03:08:30

问题


Is there some best practice or some recommended way how to validate forms in Silverlight? Right now I have to doall validation in endless nested if else structures and it just doesn't seem like a very reusable and maintainable way of doing this.

If I want to show error messages next to each form element I also have to create an empty text block next to each element which will hold the error in case the field is invalid.


回答1:


I would recommand you the Silverlight toolkit, which provides easy to use dataform and entity validation mecanisms.

there are samples describing how to use it, quite a lot of blog posts and a whole (and rather interesting) MSDN magazine article

the dataform is available in the namespace xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"

clearly, you need to reference the adequat assemblies in your project (for example System.Windows.Controls.Data.DataForm.Toolkit -pfiou-)

The samples provide code samples, bottom right of the samples browser there is a button which enables code view.




回答2:


Have a look at FluentValidation on CodePlex! It`s really comfortable to use, extend and works great with Silverlight!



来源:https://stackoverflow.com/questions/3896202/silverlight-best-practice-for-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!