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 1081027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:06:51+00:00 2026-05-16T22:06:51+00:00

I have a WPF screen that displays a number of TextBox inputs. I have

  • 0

I have a WPF screen that displays a number of TextBox inputs. I have a style that handles all the validation:

<Style x:Key="TextBoxStyle" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
    <!-- etc etc -->
    <Setter Property="Validation.ErrorTemplate">
        <Setter.Value>
            <ControlTemplate>
                <Border Grid.Column="0" BorderBrush="Red" BorderThickness="1">
                    <StackPanel>
                        <AdornedElementPlaceholder />
                    </StackPanel>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Style.Triggers>
        <Trigger Property="Validation.HasError" Value="True">
            <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}" />
        </Trigger>
    </Style.Triggers>
</Style>

The only thing I have to apply to the TextBox is to tell the binding that it validates. Seeing as I have quite a number of these boxes over the application, I would prefer not to repeat this ad nauseum for the entire application.

<TextBox Text="{Binding TargetValue, ValidatesOnExceptions=true, ValidatesOnDataErrors=true, NotifyOnValidationError=true}" Style="{DynamicResource TextBoxStyle}" />

I’ve tried adding the Text.Binding.ValidatesOnDataErrors property to the style, which doesn’t work nor seem like the correct way to do it. Is it possible to create a default binding style? Any suggestions appreciated!

  • 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-16T22:06:51+00:00Added an answer on May 16, 2026 at 10:06 pm

    Unfortunately, there’s no way of overriding the default values for Binding properties. An alternative approach you could take is to create your own custom Binding extension with ValidatesOnException and ValidatesOnDataError both set to true. In this way, you can do something like:

    <TextBox Text="{BindingWithValidation TargetValue}/>
    

    You can use the base class provided in this article to make it a bit easier to create your custom binding markup extension.

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

Sidebar

Related Questions

In WPF I have a screen for login which has a textbox for username
I have a WPF application that runs on a touch screen computer. I'd like
I'm writing an InformationKiosk WPF application that displays different full screen slides (or views),
I have a search screen in my WPF application. The screen is implemented as
I have WPF Span that is used as a source to a TextBlock. I
I have WPF C# application that communicate with a PLC (i.e. write/read Omron PLC's
I have a WPF DataGrid that increases in height when I add data to
I have a wpf application that is leaking memory...is there a way to detect
I have a WPF Keyboard Application, it is developed in such a way that
I Have a Silverlight WPF app that shows tabs of data in this case

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.