I have validation set up on the cells and it works as expected (placing a red highlight around the textbox and adding a tooltip with the error). However, If I try to access Validation.GetHasError(TheGrid) where TheGrid is my DataGrid, it is always false. Does anyone know how to check if ANY cells in the DataGrid have errors?
I want to do this so I can disable saving if there are errors.
You might run into problems with virtualization with this but you probably do have to look at the containers:
var errors = (from c in
(from object i in _myGrid.ItemsSource
select _myGrid.ItemContainerGenerator.ContainerFromItem(i))
where c != null
select Validation.GetHasError(c))
.FirstOrDefault(x => x);
if (errors)
{
//There be errors
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With