Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6585495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:40:15+00:00 2026-05-25T16:40:15+00:00

By default, the Validation.ErrorTemplate in WPF is just a small red border without any

  • 0

By default, the Validation.ErrorTemplate in WPF is just a small red border without any ToolTip.

In Silverlight 4, the validation error is nicely styled out-of-the-box.

Here is a comparison of a validation error occuring in Silverlight 4 and WPF

Silverlight 4
enter image description here
WPF
enter image description here

Notice the really flat, boring look of the WPF version compared to the, in my opinion, great look in Silverlight.

Does any similar validation styles/templates exist in the WPF Framework or has anybody created nicely styled validation templates like the Silverlight version above? Or will I have to create them from scratch?

If anybody wants to try it out, the validation error above can be reproduced with the following code, works for both Silverlight and WPF

MainWindow/MainPage.xaml

<StackPanel Orientation="Horizontal" Margin="10" VerticalAlignment="Top">
    <TextBox Text="{Binding Path=TextProperty, Mode=TwoWay, ValidatesOnExceptions=True}"/>
    <Button Content="Tab To Me..." Margin="20,0,0,0"/>
</StackPanel>

MainWindow/MainPage.xaml.cs

public MainWindow/MainPage()
{
    InitializeComponent();
    this.DataContext = this;
}

private string _textProperty;
public string TextProperty
{
    get { return _textProperty; }
    set
    {
        if (value.Length > 5)
        {
            throw new Exception("Too many characters");
        }
        _textProperty = value;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:40:15+00:00Added an answer on May 25, 2026 at 4:40 pm

    I studied the Silverlight version of the Validation Error Template and created a WPF version of it which looks like this

    enter image description here
    Added an animated GIF at the bottom of the post but after I finished it I noticed that it might be annoying because of the moving mouse in it. Let me know if I should remove it.. 🙂

    I used a MultiBinding with a BooleanOrConverter to show the “tooltip-error” when the TextBox has Keyboard focus or the Mouse is over the upper right corner. For the fade-in animation I used a DoubleAnimation for the Opacity and a ThicknessAnimation with a BackEase/EaseOut EasingFunction for the Margin

    Useable like this

    <TextBox Validation.ErrorTemplate="{StaticResource errorTemplateSilverlightStyle}" />
    

    errorTemplateSilverlightStyle

    <ControlTemplate x:Key="errorTemplateSilverlightStyle">
        <StackPanel Orientation="Horizontal">
            <Border BorderThickness="1" BorderBrush="#FFdc000c" CornerRadius="0.7"
                    VerticalAlignment="Top">
                <Grid>
                    <Polygon x:Name="toolTipCorner"
                             Grid.ZIndex="2"
                             Margin="-1"
                             Points="6,6 6,0 0,0" 
                             Fill="#FFdc000c" 
                             HorizontalAlignment="Right" 
                             VerticalAlignment="Top"
                             IsHitTestVisible="True"/>
                    <Polyline Grid.ZIndex="3"
                              Points="7,7 0,0" Margin="-1" HorizontalAlignment="Right" 
                              StrokeThickness="1.5"
                              StrokeEndLineCap="Round"
                              StrokeStartLineCap="Round"
                              Stroke="White"
                              VerticalAlignment="Top"
                              IsHitTestVisible="True"/>
                    <AdornedElementPlaceholder x:Name="adorner"/>
                </Grid>
            </Border>
            <Border x:Name="errorBorder" Background="#FFdc000c" Margin="1,0,0,0"
                    Opacity="0" CornerRadius="1.5"
                    IsHitTestVisible="False"
                    MinHeight="24" MaxWidth="267">
                <Border.Effect>
                    <DropShadowEffect ShadowDepth="2.25" 
                                      Color="Black" 
                                      Opacity="0.4"
                                      Direction="315"
                                      BlurRadius="4"/>
                </Border.Effect>
                <TextBlock Text="{Binding ElementName=adorner,
                                          Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
                           Foreground="White" Margin="8,3,8,3" TextWrapping="Wrap"/>
            </Border>
        </StackPanel>
        <ControlTemplate.Triggers>
            <DataTrigger Value="True">
                <DataTrigger.Binding>
                    <MultiBinding Converter="{StaticResource BooleanOrConverter}">
                        <Binding ElementName="adorner" Path="AdornedElement.IsKeyboardFocused" />
                        <Binding ElementName="toolTipCorner" Path="IsMouseOver"/>
                    </MultiBinding>
                </DataTrigger.Binding>
                <DataTrigger.EnterActions>
                    <BeginStoryboard x:Name="fadeInStoryboard">
                        <Storyboard>
                            <DoubleAnimation Duration="00:00:00.15"
                                             Storyboard.TargetName="errorBorder"
                                             Storyboard.TargetProperty="Opacity"
                                             To="1"/>
                            <ThicknessAnimation Duration="00:00:00.15"
                                                Storyboard.TargetName="errorBorder"
                                                Storyboard.TargetProperty="Margin"
                                                FillBehavior="HoldEnd"
                                                From="1,0,0,0"
                                                To="5,0,0,0">
                                <ThicknessAnimation.EasingFunction>
                                    <BackEase EasingMode="EaseOut" Amplitude="2"/>
                                </ThicknessAnimation.EasingFunction>
                            </ThicknessAnimation>
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
                <DataTrigger.ExitActions>
                    <StopStoryboard BeginStoryboardName="fadeInStoryboard"/>
                    <BeginStoryboard x:Name="fadeOutStoryBoard">
                        <Storyboard>
                            <DoubleAnimation Duration="00:00:00"
                                             Storyboard.TargetName="errorBorder"
                                             Storyboard.TargetProperty="Opacity"
                                             To="0"/>
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.ExitActions>
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    

    BooleanOrConverter

    public class BooleanOrConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            foreach (object value in values)
            {
                if ((bool)value == true)
                {
                    return true;
                }
            }
            return false;
        }
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rails question. The default behavior for error validation is to fieldWithError-styled div around the
How, in WPF, do you hide the validation error template adornment (red box by
Going back to the errorplacement solution by Nadia ( jQuery override default validation error
In JQuery validation the default behavior on an error is to create a label
Where are the default validation error messages in Rails 3.0? What is the equivalent
I followed the excellent post by Nadia here jQuery override default validation error message
I am using a CreateUserWizard. By default, the validation error messages are shown in
While using the default validation handling in Silverlight ( using ValidatesOnExceptions=True,NotifyOnValidationError=True), you typically get
I want to have site wide default settings for all jQuery validation uses on
By default, if a user enters a value in a field, the 'eager' validation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.