NumericUpDown ctrl 未检测到验证错误/异常
任何人都可以确认或否认 Silverlight 的 NumericUpDown 支持 NotifyOnValidationError 和/或 ValidatesOnExceptions 吗?
Can anyone confirm or deny that Silverlight's NumericUpDown supports the NotifyOnValidationError and/or ValidatesOnExceptions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它确实如此,也并非如此。
确实如此,因为它派生自
Control
,这是绑定验证机制与 UI 代码相遇的地方。它具有Valid
、InvalidFocused
和InvalidUnfocused
的常见视觉状态,并且通过设置绑定来通知验证错误,控件的视觉状态将设置为 1这个适当的状态。没有,因为工具包代码中包含的默认控件模板实际上没有任何 UI 来表示或显示验证。
因此,为了支持
NotifyOnValidationError
,您需要复制和编辑默认模板并添加一些用于验证的 UI。您可以通过查看文本框的模板来了解所需的验证 UI。It does and it doesn't.
It does because it derives from
Control
which is where the binding validation mechanism meets the UI code. It has usual visual states ofValid
,InvalidFocused
andInvalidUnfocused
and with a binding set to notify validation errors the controls visual state will be set to one of this appropriate states.It doesn't in that the default control template included in the toolkit code does not actually have any UI to represent or display the validation.
Therefore in order to support
NotifyOnValidationError
you will need to copy and edit the default template and add some UI for the validation. You can get some idea of the needed validation UI by looking at the template for a TextBox.