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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:18:08+00:00 2026-05-20T01:18:08+00:00

I’m attempting to implement the technique for data validation from Josh Smith’s example here:

  • 0

I’m attempting to implement the technique for data validation from Josh Smith’s example here: Using a viewmodel to provide meaningful validation…

My code is remarkably similar to the example, except for a few difference, namely I’m using the MVVM-Light toolkit, and my model person class is a partial class that comes from a WCF backend.

Here’s an example of the code in question:

First is the Automatically generated version of the class which comes from the WCF:

public partial class Person : BaseObject
{
    private string FooField;
    public string Foo {
        get {
                return this.FooField;
            }
        set {
                if ((object.ReferenceEquals(this.FooField, value) != true)) {
                    this.FooField = value;
                    this.RaisePropertyChanged("Foo");
                }
            }
}

I then extend the partial class to implement IDataErrorInfo:

public partial class Person : IDataErrorInfo
{

    public string Error
    {
        get { return null;}
    }

    public string this[string propertyName]
    {
        if (propertyName == "Foo")
        {
            //Do some backend Validation
        }
    }
}

And lastly I have a viewmodel:

public class PersonViewModel : INotifyProperyChanged, IDataErrorInfo
{
    private string _fooString;
    private Person _person;

    ...

    public string Foo {
        get { return _fooString; }
        set 
        {
            if (value == _fooString;)
                return;

            _fooString = value;

            RaisePropertyChanged("Foo");
        }

    public string this[string propertyName]
    {
        if (propertyName == "Foo")
        {
            string msg = Validate(Foo);  //Frontend Validation, range, format, etc.
            if(msg ! = null)
                return msg;

            _person.Foo = Foo;

        }
    }
}

So when I bind to the property in the viewmodel the validation code defined in IDataErrorInfo’s indexer gets executed on the view model and my textbox or whatever gets highlighted if my validation fails, as expected. However in my code the Indexer on the MODEL side never gets executed, at all. I can honestly say that I don’t see or understand the mechanism that is supposed to invoke it. I have run the example code from Josh Smith’s example, and it does work, calling the MV’s this[], then if validation passes the Model’s this[] hits for additional validation, but I for the life of me can’t see how it happens.

I really hope this is something simple I’m overlooking. Thanks for looking at it.

  • 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-20T01:18:08+00:00Added an answer on May 20, 2026 at 1:18 am

    You are missing

    return _person[propertyName];
    

    from the the indexer in the ViewModel.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

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.