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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:20:14+00:00 2026-06-01T20:20:14+00:00

I’m working on the validation rules for some data input forms in WPF/XAML. I’ve

  • 0

I’m working on the validation rules for some data input forms in WPF/XAML. I’ve been able to get the user experience I would like, by explicitly applying validation rules to the field bindings:

<Binding 
        Path="qtyoffset"
        NotifyOnValidationError="True"
        ValidatesOnDataErrors="True"
        UpdateSourceTrigger="PropertyChanged"
        >
    <Binding.ValidationRules>
        <utility:DecimalValidationRule precision="1" />
    </Binding.ValidationRules>
</Binding>

With the above, the field is validated on every key press. If the user enters a ‘X’, the field is immediately flagged as invalid, the error message shows up in the appropriate place, the “commit” button is immediately disabled, etc. All nice and slick. Same thing happens if the user enters two digits after the decimal point, enters two decimal points, etc.

My only problem is the verbosity. The above binding code needs to be provided for every field, and if it’s not quite right on one field, that one field will work not quite right. I’d much rather specify only the binding path, and have the rest of it added automatically. Set NotifyOnValidationError, ValidatesOnDataErrors, and UpdateSourceTrigger on every binding, set whichever validation rules are appropriate for the specific data type, depending on the type it is bound to. Or, at least, according to the type I specify in XAML.

I’m thinking about the way I would do validation in JQuery. Rather than statically listing all the validation rules on each input element, I’d set a number of classes. And then, on load, I’d use JQuery’s DOM search capabilities to find every input element with a specific class set, and dynamically add the appropriate validation functionality.

XAML provides a very nice way of providing this sort of concise configuration for display elements, using Styles and Setters. But that doesn’t work for Bindings.

Is there a reasonable alternative?

  • 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-06-01T20:20:15+00:00Added an answer on June 1, 2026 at 8:20 pm

    Short answer: No, not really.

    However you can do 2 things:

    • You can put

          NotifyOnValidationError="True"
          ValidatesOnDataErrors="True"
          UpdateSourceTrigger="PropertyChanged"
      

    in resources and access them as StaticResource, to factor out redundant information, and then you could change all of those properties in one place.

    • You can make your own markup extension based on Binding. That would make a much shorter XAML declaration. And you could use it like: <TextBox Text={local:DecimalBinding Path=qtyoffset} />

    HTH,

    Bab.

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.