I use WPF data binding with entities that implement IDataErrorInfo interface. In general my code looks like this:
Business entity:
p
You can change your person class to fire validation error only if Name property was ever changed:
public class Person : IDataErrorInfo {
private bool nameChanged = false;
private string name;
public string Name {
get { return name; }
set {
name = value;
nameChanged = true;
}
}
//... skipped some code
string IDataErrorInfo.this[string columnName] {
get {
if(nameChanged && columnName == "Name" && string.IsNullOrEmpty(Name))
return "Name is not entered";
return string.Empty;
}
}
}