0

so i have a datagridin WPF based on datasource. i created a class ValidationRule to validate all datagrid data. now for error styling u i use the RowValidationErrorTemplate with the path: Path=(Validation.Errors)/ErrorContent} now- if i want to enable/disable a button based on if theirs error or no- in that page- how could i refer to the (Validation.Errors) to check if its not empty? i tried using Validation.HasError but it was always false even when the datagrid did have wrong validation- any one?

DasDas
  • 571
  • 3
  • 9
  • 32
  • Are you implementing `IDataErrorInfo` to do your validation? That is the standard for WPF. See [this answer](http://stackoverflow.com/a/20509923/302677) for more information. – Rachel May 19 '15 at 14:37
  • no- im implementing **ValidationRule** instead – DasDas May 19 '15 at 14:39
  • Assuming your button is not in the data grid and it is binded to some different property, the button would not disable because the datagrid's binding is failing and not button's. Can you share code snippet of your xaml. Ideally you need to disable button by referring to your data grid in a button's Style Trigger. – Versatile May 19 '15 at 14:42
  • Check here http://stackoverflow.com/questions/6509541/disabling-button-on-validation-error – Versatile May 19 '15 at 14:45
  • @DasDas I believe XAML's `Validation.Errors` uses the `IDataErrorInterface`, so if you want to use that kind of syntax in your XAML you should implement `IDataErrorInfo` for your validation instead. ValidationRules are more for WinForms than WPF. – Rachel May 19 '15 at 14:59
  • @Rachel but my datagrid is bind to a datasource not a class object – DasDas May 20 '15 at 07:54

0 Answers0