Validating datagrid cell values using Enterprise Library config file
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}" SourceProper开发者_StackOverflowtyName="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.
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.
精彩评论