WPF Validation & IDataErrorInfo
Posted
by Jefim
on Stack Overflow
See other posts from Stack Overflow
or by Jefim
Published on 2010-03-22T12:22:16Z
Indexed on
2010/03/23
6:53 UTC
Read the original article
Hit count: 453
A note - the classes I have are EntityObject
classes!
I have the following class:
public class Foo
{
public Bar Bar { get; set; }
}
public class Bar : IDataErrorInfo
{
public string Name { get; set; }
#region IDataErrorInfo Members
string IDataErrorInfo.Error
{
get { return null; }
}
string IDataErrorInfo.this[string columnName]
{
get
{
if (columnName == "Name")
{
return "Hello error!";
}
Console.WriteLine("Validate: " + columnName);
return null;
}
}
#endregion
}
XAML goes as follows:
<StackPanel Orientation="Horizontal" DataContext="{Binding Foo.Bar}">
<TextBox Text="{Binding Path=Name, ValidatesOnDataErrors=true}"/>
</StackPanel>
I put a breakpoint and a Console.Writeline
on the validation there - I get no breaks. The validation is not executed. Can anybody just press me against the place where my error lies?
© Stack Overflow or respective owner