Silverlight 中的验证

发布于 2024-08-02 15:34:55 字数 119 浏览 2 评论 0原文

如何验证silverlight控件的输入形式? 我有 3 个控件,其中三分之二是文本框(姓名和年龄),剩下的一个控件是日期选择器。

当我点击提交按钮时,应该调用验证。它将如何完成?

提前致谢。

how to validate the input form of a silverlight control?
I have 3 controls, two out of three are text boxes (For name, and Age), and the remaining one control is date picker.

When i hit submit button, the validation should be invoked. how it will done??

thanks in advance.

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

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

发布评论

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

评论(3

╰つ倒转 2024-08-09 15:34:55

如果您使用的是 Silverlight 3,请查看数据验证。 http://www.silverlightshow.net/items/Data- Validation-in-Silverlight-3.aspx

如果您使用的是 Silverlight 2,则必须滚动自己的代码进行验证。

If you're using Silverlight 3 check out Data Validation. http://www.silverlightshow.net/items/Data-Validation-in-Silverlight-3.aspx

If you're using Silverlight 2 you'll have to roll your own code for validation.

╄→承喏 2024-08-09 15:34:55

我为 SL2 编写了自己的验证。它基于:

  1. 为控件提供自定义验证 ID 的附加属性
  2. 识别无效数据的业务对象验证器
  3. VisualTreeHelper 用于解析可视化树并匹配验证结果和自定义验证 ID
  4. 控件的自定义模板,用于显示验证
  5. INotifyPropertyChanged 用于在属性值是时删除验证显示改变了。

I wrote my own validaion for SL2. It's based on:

  1. Attached property to give control custom validation ID
  2. Business object validators that identify invalid data
  3. VisualTreeHelper to parse visual tree and match validation result and custom validation ID
  4. Custom templates for controls in order to display validation
  5. INotifyPropertyChanged to remove validation display if property value was changed.
晨曦÷微暖 2024-08-09 15:34:55

您还可以找到验证应用程序块(它是企业库 Silverlight 集成包)很有用。它现在处于公共预览状态。

You may also find the Validation Application Block (which is part of the Enterprise Library Silverlight Integration Pack) useful. It's in public preview right now.

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