I've got a ViewModel implementing INotifyDataErrorInfo, and a View bound to that ViewModel.
The ViewModel contains a property of type Double, and in the View, a TextBox whose Text property is bound to that Double property.
public double Value
{
get { return _value; }
set
{
_value = value;
NotifyPropertyChangedAndValidate();
}
}
<TextBox Text="{Binding Path=Value, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
Inside the viewModel's indexer (from INotifyDataErrorInfo), I can validate the inserted value, for instance check if it doesn't exceed a certain boundary. Such an error message then I can display via <ItemsControl ItemsSource="{Binding Path=Errors}" ItemTemplate="{StaticResource ResourceKey=WrapTemplate}" />
But, when invalid characters are inserted into the textBox, then the indexer (or the whole INotifyDataErrorInfo implementation) doesn't get that value, so he cannot produce an error message suitable to that faulty insertion. How can I achieve, that error messages coming from the indexer can be displayed on the screen in the same behaviour like that ones generated internally by .NET, when invalid characters are inserted?