Reputation: 4498
I have my own errorprovider and do not want to use any of the built in WPF stuff. I have a textbox that is bound to an integer, and I have ValidatesOnExceptions=False and ValidatesOnDataErrors=False. But when I enter a non integer in the textbox I get a red border. Is there something I'm missing?
Upvotes: 3
Views: 1057
Reputation: 24403
You have several options
You can use a custom value converter that doesn't throw an exception when your try to coax a string into an integer
class CustomConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
int x = -1;
Int32.TryParse(value.ToString(), out x);
return x;
}
}
You can change the UpdateSourceTrigger to explicit and have control over the precisely when databinding is updated.
You can use expression blend to edit a local copy of TextBox template and remove all things related to binding validation errors
Upvotes: 2