I'm working with the XamGrid, and I am using a custom Validation Attribute that I created. This attribute throws a Validation exception when there are problems with the value being set for a property. The XamGrid doesn't handle this like other Validation Attributes, and instead of catching the Exception or ValidationException it ends up being handled by the Application.
Is there a way to indicate to the XamGrid to validate on Exceptions, as if I were setting that option within the Binding?
Below is the code that throws the exception.
double Value = (double)0; try { if (value.GetType() != typeof(decimal)) { Value = (double)value; } else { Value = Convert.ToDouble(value); } if (Value >= this.Minimum) { return ValidationResult.Success; } else { throw new ValidationException(string.Format(this.ErrorMessage != null ? this.ErrorMessage : "The entered value must be greater than {0}.", this.Minimum.ToString())); } } catch (InvalidCastException) { throw new ValidationException(this.ErrorMessage != null ? this.ErrorMessage : "The entered value must be numeric."); }
XamGrid Version 10.3
Hi Benji,
you need just to set the column's property AllowEditingValidation="True" for the columns you need validation. For TemplateColumn and Unbound column you can specify validation options in the binding in your EditorTemplate.
Hope this Helps,
I attempted that yesterday, but it didn't change the problem.
I am attaching a sample illustrating the exception validation. Take a look at the columns with keys IntegerData and StringData.
HTH,