ValidatesOnExceptions
intended to display custom exceptions. But if you have a TextBox
associated with the int
property, then before the binding occurs, a conversion will occur that can cause a "red border".
To try
<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; } } }
Enter a number for each text field:
- Red border due to data conversion
- There is no red border because ValidatesOnExceptions is false
- Red border, because ValidatesOnExceptions are true,
I hope this helps.
source share