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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:55:44+00:00 2026-05-18T23:55:44+00:00

My question is more along the lines of a good practice when using INotifyPropertyChanged.

  • 0

My question is more along the lines of a good practice when using INotifyPropertyChanged.

I’ve created a base class that implements INotifyPropertyChanged, with the intention that this class will be used in most custom view-model binding circumstance.

Basically I have a DispatchPropertyChange method that takes the name (string) of the property changing. This is pretty straight forward, but strings are obviously error prone.

I would like to verify that the property is valid before dispatching, but I’m not sure if this is a good approach. So far my helper function looks like this.

private void ValidateProperty( string prop )
{
    if( TypeDescriptor.GetProperties(this)[prop] == null )
    {
        //throw error
    }
} 

I’m thinking this strategy could slow things down.
Does anyone have another approach, or method of verifying that a property name is valid?

  • 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-18T23:55:44+00:00Added an answer on May 18, 2026 at 11:55 pm

    Many implementations (usually slight differences) of dealing with the loosely typed issue of INotifyPropertyChanged.PropertyChanged exist.

    Portion of one example is below; which deals with your null check…

    protected void RaiseChanged<TProperty>(Expression<Func<TProperty>> propertyExpresion)
    {
        var property = propertyExpresion.Body as MemberExpression;
        if (property == null || !(property.Member is PropertyInfo) ||
            !IsPropertyOfThis(property))
        {
            throw new ArgumentException(string.Format(
                CultureInfo.CurrentCulture,
                "Expression must be of the form 'this.PropertyName'. Invalid expression '{0}'.",
                propertyExpresion), "propertyBLOCKED EXPRESSION;
        }
    
        this.OnPropertyChanged(property.Member.Name);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is more like a strategy question: I need to check regularly a long
This is related to my previous question More than 1 Left joins in MSAccess
This is a code review question more then anything. I have the following problem:
ASP.Net MVC3 is cool and all but I have this question more out of
This question is more UI/Design-ish than hard-core programming is. Background: I've been coding in
This question is more about guidance than actually solving my problem: I need to
This question is more a re-insurance than one directly about how to code. As
EDIT: This question is more about language engineering than C++ itself. I used C++
I've integrated ActiveMerchant into my Rails 3 app more or less along the lines
A similar question has been asked here: Class members that are objects - Pointers

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.