似乎其他人遇到了这个问题: Validation.HasError does not trigger again if new error come in while already true
Validation.Error 未使用最新的错误消息进行更新。
它显示上一个错误,而不是最后一个实际调用的错误。当我记录每次返回时,返回的 PropertyX 大于或 PropertyX 小于,但它不会在我的工具提示中显示该消息。它将显示“必需”。
我还发现,当返回 PropertyX 大于或 PropertyX 小于时,我的工具提示转换器不会被调用。
这是验证代码:
string this[string columnName]
{
get
{
switch(columnName)
{
case "Property1":
int output;
if (true == string.IsNullOrEmpty(this.Property1))
{
return "Required";
} else if (true == int.TryParse(this.Property1, out output))
{
return "Invalid integer";
} else if (true == this.Property1Int.HasValue &&
true == this.Property2Int.HasValue)
{
if (this.Property1Int.Value < this.Property2Int.Value)
{
return "Property2 is greater than Property1";
}
}
break;
case "Property2":
int output;
if (true == string.IsNullOrEmpty(this.Property2))
{
return "Required";
} else if (true == int.TryParse(this.Property2, out output))
{
return "Invalid integer";
} else if (true == this.Property1Int.HasValue &&
true == this.Property2Int.HasValue)
{
if (this.Property2Int.Value > this.Property1Int.Value)
{
return "Property2 is greater than Property1";
}
}
break;
};
return string.Empty;
}
}
到底是怎么回事?