使用 Enterprise Library 配置文件验证数据网格单元格值
在我的应用程序中,我正在使用 MVVM 设计模式处理 WPF,使用配置文件通过企业库进行验证。 我想通过企业库配置文件验证我的网格单元值。在我的视图模型中,我有一个 objservalble 集合属性,该属性绑定到视图中的数据网格。 然后,我想使用企业库验证我的单元格值之一以进行范围验证。但是我没有找到任何正确的方法来执行相同的操作。我不想使用任何自定义验证器,而是想通过企业库来实现仅配置文件。
实际上,在向数据网格列添加验证时,我们的绑定如下:-
<xa:ValidatorRule RulesetName="NameOfRuleset" SourceType="{x:Type vm:ViewModelType}" SourcePropertyName="NameOfProperty" ValidationSpecificationSource="Configuration" ValidatesOnTargetUpdated="True" />
但在这种情况下,我的视图模型不会有专门针对该字段的属性,而是有集合,所以我坚持如何做同样的事情, 任何人都可以指导我如何实现同样的目标。如果我的解释不够清楚,请告诉我。
In my application,I am working on WPF with MVVM design pattern doing validations through Enterprise Library using configuration file.
I want to validate my grid cell values through enterprise library configuration file.In my view model I have an objservalble collection property that is bound to the datagrid in a view.
Then,I want to validate one of my cell value for range validation using enterprise library..But I am not finding any proper way to do the same.I don't want to use any custom validator rather want to achieve with the enterprise library configuration file only.
Actually while adding a validation to datagrid column we are binding like:-
<xa:ValidatorRule RulesetName="NameOfRuleset" SourceType="{x:Type vm:ViewModelType}" SourcePropertyName="NameOfProperty" ValidationSpecificationSource="Configuration" ValidatesOnTargetUpdated="True" />
But as in this case my view model will not have a property specifically for this field rather it has collection,so i am stucked on how to do the same,
Can anyone please guide me how to achieve the same.Please let me know if my explanation is not clear enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了同样的解决方案。
为我的收藏又创建了一堂课在配置文件和视图中,我仅引用该类类型,而不是引用我的视图模型。
我创建新类的原因是我正在使用实体框架&我无法在 UI 中引用 DAL 层,但我可以在视图中引用我自己的类型。
通过这种方式,它解决了我将验证规则添加到绑定到集合的数据网格的问题。
如果有人需要示例代码,请告诉我我可以提供相同的代码。
Found a solution for the same.
Created a one more class for my collection & in configuration file as well as in view I am refering to that class type only instead of refering to my viewmodel.
Reason why I created new class is I am using Entity framework & i cannot refer to DAL layer in my UI but I can refer to my own type in view.
In this way it solved my problem of adding validation rules to the datagrid that is binded to the collection.
Incase anybody needs sample code,let me know I can provide the same.