Detecting validation errors in Silverlight 4
- by jkohlhepp
I'm using the new Silverlight 4 support for IDataErrorInfo.  So I have a POCO object that has implemented the interface, and when a validation rule fires the Silverlight UI correctly shows the error.  So that is all working fine.
The POCO object looks like this:
public class SomeDomainClass : IDataErrorInfo
{
    public string SomeString { get; set; }
    public string Error
    {
        get { return String.Empty; }
    }
    public string this[string columnName]
    {
        get
        {
            if (columnName == "SomeString" && PolicyNumber.Contains("%"))
                return "SomeString cannot contain '%'.  You'll ruin everything!!!";
            return String.Empty;
        }
    }
}
However, I want to be able to detect whether or not there are any errors on the page.  For example if I have a Save button and I want to disable it if there are errors, or display a message or something.
What is the best way to detect if there are existing validation errors on the page?  Is there a facility for this based around the IDataErrorInfo support in Silverlight?  Or do I have to track it in the domain model myself?