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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:15:56+00:00 2026-05-26T03:15:56+00:00

What I have so far is: A WPF application, using MVVM, IDataErrorInfo implemented. Everything

  • 0

What I have so far is: A WPF application, using MVVM, IDataErrorInfo implemented. Everything is working as expected.

Every time I open a “Create New Entity” dialog, the user is saluted with a nice form, flashing red all over the place. This is expected in a pure validation point of view, but it is annoying and I would like to be able to do either one of two thing.

  1. “Soften” the red error highlighting color to lets say orange, or yellow, to indicate “Required field”. Subsequently, when the user starts interacting with the controls switch to the red highlighting
  2. If that’s not possible, is there a way to disable error highlighting @ initial state?

I found this post How can I get WPF to NOT display validation errors upon initial display of control? dealing with the same problem, but it is not really answered.

I considered implementing a “Clear All error” within my IDataErrorInfo implementation, as well as implementing an InitialState flag, so errors wont be added until at least one field was changed by the user, but those have side-effects.

  1. If I clear all errors after init, the validation is off, but the submit button is, of course, enabled 🙁
  2. If I use an InitialState flag, which is also bound to the submit button to disable it… I get one step further, but then ALL errors are added with the change in one single property field.

So before I go and add InitState flags for EACH property, I though I stop and ask if there might be a simpler, more generic solution to this.

I can post some code if required. However, I implement the IDataErrorInfo in a standard way, a Dictionary<string,string> for the error messages, the Property Fields with OnChange Events and a switch case statement to call individual validation methods.

EDIT:
Here is what I ended up with.

  1. I added an IsInitState=true flag for each ‘Required’ field property in the VM
  2. In the setter code this flag is set to false on first change

            if (Name != value)
            {
                Name = value;
                IsInitState_Name = false; 
                base.OnPropertyChanged("Name");
            }
    
  3. In the ValidateName (), the Null/empty test is conditional based on the flag

    if (!IsInitState_Name && String.IsNullOrEmpty(this.Name))

  4. Submit button “canExecute” checks if all flags are == false before enabling submit

  5. It’s some extra work, but only needed for “required / non-null able” properties. Now the Create new interface is initially without error messages yet validation is fully functional

  • 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-26T03:15:57+00:00Added an answer on May 26, 2026 at 3:15 am

    One option is to not consider the initial ’empty’ state to be invalid (thus not causing the UI to reflect an error), but to do a separate set of checks (including non-empty) before allowing a Commit. In this case, you can set an error for each property that was ’empty’ when the Commit was attempted. One consequence of this is that making a box empty by editing the text will clear any error on the box, but that may not be too terrible.

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

Sidebar

Related Questions

I am using MVVM architecture to develop a WPF application... So far everything has
I have a small WPF application based on MVVM priniciples. So far I had
I'm creating a WPF application using the MVVM design pattern that consists of a
I'm working in a WPF project, I'm using the MVVM patter in my project.
I'm about to create WPF application. So far at uni the only way we
im learning wpf for the first time, i have made this far private void
OK, every other browser works fine with the method I have coded so far
I have an application that has several objects (about 50 so far, but growing).
I've just been reading Josh Smith's MVVM article and am working on a WPF
I'm buidling an WPF application using the examples given in the link below as

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.