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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:09:20+00:00 2026-06-07T07:09:20+00:00

So it’s like this, I have a wpf binding <TextBox Name=txtRackNo Grid.Column=5 Grid.ColumnSpan=7 Grid.Row=4

  • 0

So it’s like this, I have a wpf binding

<TextBox
        Name="txtRackNo"
        Grid.Column="5"
        Grid.ColumnSpan="7"
        Grid.Row="4"
        Grid.RowSpan="1"
        Style="{StaticResource ResourceKey=styleValidationTextBox}"
        Text="{Binding Path=rack_no, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}">
</TextBox>

If I implement IDataErrorInfo and have property directly in my viewmodel, then it works, it shows the tooltip and red validation box.
If I implement IDataErrorInfo in a class that is a property of my viewmodel, the style creates the tooltip, but the red error box does not show up. I am sure that my style is working, it is just that if I change this line

Text="{Binding Path=rack_no, Mode=TwoWay, ...}" 

to use my datatype “RACK”

Text="{Binding Path=rack.rack_no, Mode=TwoWay, ...}"

private Rack _rack;
public Rack rack
{
    get { return _rack; }
    set
    {
        _rack = value;
        createPropertyObserver();
        base.RaisePropertyChanged("rack");
    }
}

then it only shows the tooltip and not the red validation error box.

EDIT: Here is more code, maybe this will help someone to understand my question better?

class Rack : ObservableObject, IDataErrorInfo
{
    public String _rack_no;
    public String rack_no
{
         get { return _rack_no; }
    set
    {
    if (value != null)
    {
        _rack_no = value;
        base.RaisePropertyChanged("rack_no");
    }
    }
}

     public String Error
    {
        get { return this[null]; }
    }

    public String this[String propertyName]
    {
        get
        {
            String result = String.Empty;
            propertyName = propertyName ?? String.Empty;
            if (propertyName == String.Empty || propertyName == "dc_name")
            {
                if (String.IsNullOrEmpty(this.dc_name))
                {
                    result += "Datacenter name is mandatory." + Environment.NewLine;
                }
            }

            if (propertyName == String.Empty || propertyName == "rack_no")
            {
                if (String.IsNullOrEmpty(this.rack_no) || this.rack_no.Length > 5)
                {
                    result += "Rack number is mandatory and must be 5 letters or less."
                        + Environment.NewLine;
                }
            }
            Debug.WriteLine(result);
            return result.TrimEnd();
        }
    }

Then here is part of my viewmodel:

              private Rack _rack;
    public Rack rack
    {
        get { return _rack; }
        set
        {
            _rack = value;
            createPropertyObserver();
            base.RaisePropertyChanged("rack");
        }
    }

If in my view, I bind the text box to rack.rack_no, if there is a validation error, the tooltip works and shows the proper error message. However, it does not change the textbox to use the validationstyle.

If I create the same property (rack_no) and implement idataerrorinfo in my viewmodel, then I bind to this instead, it works perfect.

I just want to know if I am doing something wrong here, like is this not a valid binding for validation? is there a way to allow me to continue to bind to the rack.rack_no class and use validation?

  • 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-07T07:09:22+00:00Added an answer on June 7, 2026 at 7:09 am

    Scrapped this idea and instead decided to use the method given in the below:
    http://www.codeproject.com/Articles/15239/Validation-in-Windows-Presentation-Foundation
    and
    http://www.codeproject.com/Articles/97564/Attributes-based-Validation-in-a-WPF-MVVM-Applicat

    This use idataerrorinfo in combination with System.ComponentModel.DataAnnotations; to perform validation. I also changed my validation style to manually create the red box which seems to have fixed the problem with using the default validation style while validating databindings which are bound to child objects.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have two tables with like below codes: Table: Accounts id | username |
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I would like to count the length of a string with PHP. The string

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.