Data Validation Exception with Windows Community Toolkit MVVM
When using validations InView and we use MVVM from WKT 7.1.2 we get the following exception
System.InvalidCastException: Unable to cast object of type 'System.ComponentModel.DataAnnotations.ValidationResult' to type 'System.String'.
The problem is that GetErrros return a enumeration of ValidationResult defined in System.ComponentModel.DataAnnotations
System.Collections.IEnumerable GetErrors(string propertyName)It appears if you doing an explicit cast for the elements to string... like this (string)obj. Maybe it should be better to use ToString() or cater for ValidationResult
For more info regarding the MVVM from the toolkit see
Thanks
Stephanus
Your DataGrid Validation does not work with Prism MVVM or Windows Community Toolkit MVVM.
According to this Data Validation in UWP DataGrid control | Syncfusion I need to do my own implementation of INotifyDataErrorInfo. Those MVVM frameworks already did that plumbing and their implementations break with Syncfusion DataGrid.
It seems like your DataGrid expects a System.Collections.IEnumerable<string> from INotifyDataErrorInfo.GetErrors but the MVVM Frameworks return System.Collections.IEnumerable<ValidationResult>
When Validation fail the UWP app crash because it thinks the results are strings and not ValidationResult
We regret for inconvenience.
We regret to inform you that we have tried to replicate the reported problem but unable to replicate the issue from our end. Can you please provide the issue reproducible sample and steps to replicate the issue.
It will be more helpful for us to find the exact cause for the issue and to provide a prompt solution.
Regards,
- 3 Replies
- 3 Participants
-
ST Stephanus
- Nov 26, 2021 11:10 AM UTC
- Dec 3, 2021 02:04 PM UTC