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

  • Home
  • SEARCH
  • 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 3483374
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:40:01+00:00 2026-05-18T10:40:01+00:00

I have an issue with validation in WPF that I can’t seem to resolve.

  • 0

I have an issue with validation in WPF that I can’t seem to resolve. I have a class (that implements IDataErrorInfo) that uses a property like-so.

private double? _SizeSearchValue;
public double? SizeSearchValue
{
  get { return _SizeSearchValue; }
  set
  {
    _SizeSearchValue = value;
    NotifyChange("SizeSearchValue");
    ValidateInputRow("SizeSearchValue");
  }
}

It is bound to a textbox in XAML like this.

      <StackPanel Orientation="Horizontal">
        <TextBlock VerticalAlignment="Center"  Text="Size:"/>
        <ComboBox Text="{Binding SizeSearchOption, ValidatesOnDataErrors=True}"/>
        <TextBox Text="{Binding SizeSearchValue, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=False}"/>
      </StackPanel>

The ValidateInputRow() function in the property setter will normally go through and run my custom validation routines and set errors appropriately so that the ComboBox and TextBox in the StackPanel mention above have a red border. Everything works just fine until I put a non-numeric string into the Textbox (“Abc” for example.)

With string input the binding runs its default validation, a FormatException is raised and the textbox gets its red border as per usual. My problem with this is that my custom validation routine will never run because the property setter in my class is never called.

I understand why this is happening, but I was wondering if anyone knew a way to catch an event, or the offending FormatException so that I can run my custom validation after the fact. I can’t seem to figure this one out.

  • 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-18T10:40:01+00:00Added an answer on May 18, 2026 at 10:40 am

    OK, Looks like I answered my own question. I looked further into the FormatException stack trace and found that an ‘IValueConverter’ is involved in the process so….. A solution is to use a converter like so:

    <TextBox Text="{Binding SizeSearchValue, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource TestConverter}}"/>
    

    In my case I just whipped one up (TestConverter) real quick and tied it up to my custom validation rules. Problem solved. I wonder if there are any equivalent solutions to the problem?

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

Sidebar

Related Questions

Here's my issue: I have a html form that after a user fills in
I have got a very strange input issue in which it seems that my
I have a WPF textbox on a form to allow input of a URI.
I have an issue with submitting post data. I have a form which have
I have an issue when I click on a link to edit a sale
I am building a WebPages site and have an issue when I try to
I have a design issue. I need to implement a listener. I saw the
Issue: Hello, I have an edit page which enables the client to update the
I have a simple subscribe form at : http://thepanamainsider.com/sanblas/index9.php The form doesn't work, it
I have dynamic form about posting room ad and first option is: Room in:

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.