在 WPF 中触发数据验证
我在 WPF 中遇到验证问题。
我有一个用户控件,它有几个文本框,它们绑定到数据模型。
验证是通过 IDataErrorInfo 实现的。
我希望仅当用户按下“提交数据”按钮时才触发验证,因此我将 UpdateSourceTrigger="Explicit"
与所有这些文本框的绑定一起使用。
一切工作正常,只有当用户按下按钮时才会触发验证,我会在其中更新数据源。
但是该用户控件可以隐藏或显示,当我将可见性从显示/更改为隐藏然后返回显示时,会触发验证。
有没有办法控制该阶段的验证?
I have a problem in WPF with validation.
I have a user control which has few textboxes, which are binding to datamodel.
The validation is implemented with IDataErrorInfo.
I want the validation to be triggered only when the user press the button "Submit data", so I used UpdateSourceTrigger="Explicit"
with the binding of all those text boxes.
Everything working fine, and the validation only triggered when the user push the button, where I update the datasources.
But that user control can be hidden or shown, and when I changed the visibility from display/ to hidden and then back to display, the validation is triggered.
Is there a way to control the validation on that stage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我正在使用的代码
绑定到文本框
正在执行验证和搜索的代码(与单击名为“搜索”的按钮相关)
This is the code that I am using
The binding to the textbox
The code that is executing the validation and search (which is associated to click of a button called "Search")