Question: I will like to validate user entry to ensure they are integers. How can I do it? I thought of using `IDataErrorInfo` which seems like the "correct" way to do validation in WPF. So I tried implementing it, in my ViewModel.

But the thing is my text box is bound to an integer field, and there isn't any need to validate if an `int` is an `int`. I noticed that WPF automatically adds a red border around the textbox to notify the user of the error. The underlying property doesn't change to an invalid value. But I would like to notify the user of this. How can I do it?

Answer: 
The red border you've seen is actually a ValidationTemplate, which you can extend and add a info for the user. See this example:

```
    <UserControl.Resources>
        <ControlTemplate x:Key="validationTemplate">
            <Grid>
                <Label Foreground="Red" HorizontalAlignment="Right" VerticalAlignment="Center">Please insert a integer</Label>
                <Border BorderThickness="1" BorderBrush="Red">
                    <AdornedElementPlaceholder />
                </Border>
            </Grid>
        </ControlTemplate>
    </UserControl.Resources>

<TextBox Name="tbValue" Validation.ErrorTemplate="{StaticResource validationTemplate}">

```
if you are working in WPF Better to use PreviewTextInput event which support all platforms and from presentationcore.dll

here is the example:

```
private void TextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
    {
        if ((e.Text) == null || !(e.Text).All(char.IsDigit))
        {
            e.Handled = true;
        }
    }

```