我有一个TextBox实现的对象的属性绑定IDataErrorInfo.我成立Validation.ErrorTemplate的TextBox,并能正常工作.问题是我在a上有这些TabControl,如果我将标签更改为另一个标签然后返回到初始标签(其中TextBox),则验证模板不再显示.它看起来像是经过验证的(就像值是正确的),但实际上并非如此.
这是IDataErrorInfo对象 - 请注意,"正确"值是一个长度为2的字符串:
public class Presenter : IDataErrorInfo
{
public Presenter()
{
this.Property = String.Empty;
}
public string Property { get; set; }
public string Error { get { return null; } }
public string this[string columnName]
{
get
{
if (columnName == "Property")
{
if (this.Property.Length == 2)
return null;
else
return "Invalid property length!";
}
else return null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是XAML:
<TabControl …Run Code Online (Sandbox Code Playgroud)