When using the ErrorProvider with the IDataErrorInfo interface duplicate error messages are displayed by the ErrorProvider control. The ErrorProvider control never displays a false positive, but if there is an error then the error message is displayed multiple times by the ErrorProvider control. Any ideas?
$0$0
$0
$0 private const string EMAIL_ERROR_NULL = "Email Address cannot be empty.";$0
$0 private const string emailPattern = @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&;;'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$";$0
$0
$0private readonly Dictionary<String, List<String>> errors = new Dictionary<string, List<string>>();$0
$0
$0$0
$0
$0 private bool IsEmailValid(string value)$0
$0 {$0
$0 bool isValid = true;$0
$0$0
$0
$0 if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value))$0
$0 {$0
$0 AddError("Email", EMAIL_ERROR_NULL, false);$0
$0 isValid = false;$0
$0 }$0
$0 else$0
$0 RemoveError("Email", EMAIL_ERROR_NULL);$0
$0$0
$0
$0 if (!Regex.IsMatch(value, emailPattern))$0
$0 {$0
$0 AddError("Email", EMAIL_ERROR_INVALID, false);$0
$0 isValid = false;$0
$0 }$0
$0 else$0
$0 RemoveError("Email", EMAIL_ERROR_INVALID);$0
$0$0
$0
$0 return isValid;$0
$0 }$0
$0
$0$0
$0
$0
$0 // Adds the specified error to the errors collection if it is not already $0
$0 // present, inserting it in the first position if isWarning is false. $0
$0 public void AddError(string propertyName, string error, bool isWarning)$0
$0 {$0
$0 if (!errors.ContainsKey(propertyName))$0
$0 errors[propertyName] = new List<string>();$0
$0$0
$0
$0 if (!errors[propertyName].Contains(error))$0
$0 {$0
$0 if (isWarning) errors[propertyName].Add(error);$0
$0 else errors[propertyName].Insert(0, error);$0
$0 }$0
$0 }$0
$0$0
$0
$0 // Removes the specified error from the errors collection if it is present. $0
$0 public void RemoveError(string propertyName, string error)$0
$0 {$0
$0 if (errors.ContainsKey(propertyName) &;;&;;$0
$0 errors[propertyName].Contains(error))$0
$0 {$0
$0 errors[propertyName].Remove(error);$0
$0 if (errors[propertyName].Count == 0) errors.Remove(propertyName);$0
$0 }$0
$0 }$0
$0