I am using the RadGridView control in an MVVM (Light) application. I added the following EventToCommandBehaviors to initiate row validation when leaving the selected row:
<telerik:EventBinding EventName="RowValidating" Command="{Binding ValidateCommand}" PassEventArgsToCommand="True"/>
<telerik:EventBinding EventName="RowEditEnded" Command="{Binding SaveCommand}" PassEventArgsToCommand="True"/>
Here's the method and helper method that gets called and works like it should to add the error:
private void ExecuteValidate(GridViewRowValidatingEventArgs eventArgs)
{
var employee = eventArgs.Row.DataContext as Employee;
if (employee?.RecId == (int)RecEnum.CertainState && employee.OtherRecId == null)
{
var validationResult = new GridViewCellValidationResult
{
PropertyName = "ColumnUniqueName",
ErrorMessage = "Must enter a OtherRecId when RecId is set to CertainState"
};
eventArgs.ValidationResults.Add(validationResult);
}
if (eventArgs.ValidationResults.Count > 0)
{
eventArgs.IsValid = false;
}
}
And finally, following the instructions of removing the UserDefinedErrors, I add the following line in the RowEditEnded event:
eventArgs.UserDefinedErrors.Clear();
If I fix the error, the row is saved, but the mouseover error message remains even though there are no errors. I followed your directions by adding the eventArgs.UserDefinedErrors.Clear(), but this didn't help.
Does anyone have any workarounds or must this bug be fixed?
Thanks for your help.