简体   繁体   English

资源样式C#中的wpf中的控件验证

[英]Control validation in wpf which is inside a resource style C#

I'm using navigation window in wpf which has a style applied on it. 我正在wpf中使用导航窗口,该窗口上已应用了样式。 Inside that style there are textboxes. 在该样式内有文本框。 I use MVVM pattern and my model implements IDataErrorInfo and returns error for these textboxes. 我使用MVVM模式,并且我的模型实现IDataErrorInfo并为这些文本框返回错误。 Everything releated to data binding works just fine, but validation highlighting fails. 与数据绑定相关的所有内容都可以正常工作,但是突出显示验证失败。 There is no problem with styles, I have set special style for validation error for these textboxes. 样式没有问题,我为这些文本框设置了特殊的验证错误样式。 When I use the same not inside resource, then valdiation works correct. 当我使用相同的不在内部的资源时,校验正确。

You need to make sure your Style is an implicit style so it gets applied to your TextBoxes. 您需要确保您的样式是隐式样式,以便将其应用于文本框。 If you have an x:Key on your style, then remove it. 如果样式上有x:Key,则将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM