based on this example
http://msdn.microsoft.com/en-us/library/system.windows.data.binding.validatesonexceptions.aspx
It seems that ValidatesOnExceptions is responsable to catch the custom exception and add it to Validation.Errors collection.
The problem is I have the same behavior even with ValidatesOnExceptions set to false
Could someone explain what I am missing?
Thanks
ValidatesOnExceptions
is for custom exception display. But if you have TextBox
bound to an int
property then before the binding happen a conversion occurs which could cause "red border".
To try it out
<TextBox Text="{Binding IntField}"/>
<TextBox Text="{Binding StringField, ValidatesOnExceptions=False}"/>
<TextBox Text="{Binding StringField, ValidatesOnExceptions=True}"/>
public int IntField { get; set; }
private string stringField;
public string StringField
{
get { return stringField; }
set
{
throw new Exception(); text = stringField; }
}
}
Type a number to each textbox:
I hope it helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With