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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:21:08+00:00 2026-05-16T10:21:08+00:00

All the examples of Silverlight using MVVM use interface named IPropertyChanged. What is the

  • 0

All the examples of Silverlight using MVVM use interface named IPropertyChanged. What is the concept behind it and why do we need to raise an event whenever we set some value?

Eg:-

public class UserNPC:INotifyPropertyChanged
{
    private string name;
    public string Name { 
        get { return name; } 
        set { name = value; onPropertyChanged(this, "Name"); } 
    }
    public int grade;
    public int Grade { 
        get { return grade; } 
        set { grade = value; onPropertyChanged(this, "Grade"); } 
    }

    // Declare the PropertyChanged event
    public event PropertyChangedEventHandler PropertyChanged;

    // OnPropertyChanged will raise the PropertyChanged event passing the
    // source property that is being updated.
    private void onPropertyChanged(object sender, string propertyName)
    {
        if (this.PropertyChanged != null)
        {
            PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));
        }
    }
}

What is the exact purpose of INotifyPropertyChanged?

  • 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-16T10:21:09+00:00Added an answer on May 16, 2026 at 10:21 am

    You have the following dependencies:

    View → Binding → Model

    Now, the concept is as following:

    If some data in your Model object changes, you are required to raise the PropertyChanged event. Why? Because the Binding object has registered a method with the data object’s PropertyChanged event.

    So all you have to do when something changes within your Model object is to raise the event and you are done.

    When you do that, the Binding object gets notified about the change through your event. The Binding object in turn lets the View object know that something happened. The View object then can update the UI if necessary.

    Code example

    Here you have a compilable example. Set a few breakpoints, step through the code with F11 and see what happens behind the scenes. Note that this example has the following dependency: View → Model. I left out the Binding object.

    using System;
    using System.ComponentModel;
    
    namespace INotifyPropertyChangedDemo
    {
        class Program
        {
            static void Main(string[] args)
            {
                // Create 2 listeners.
                View1 view1 = new View1();
                View2 view2 = new View2();
    
                // Create 1 data object.
                Model model = new Model();
    
                // Connect listener with data object.
                model.PropertyChanged += new PropertyChangedEventHandler(view1.MyPropertyChangedEventHandler);
                model.PropertyChanged += new PropertyChangedEventHandler(view2.MyPropertyChangedEventHandler);
    
                // Let data object publish change notification.
                model.FirstName = "new name";
    
                // Check whether all listeners got notified.
                // ... via console.
            }
    
            public class Model : INotifyPropertyChanged
            {
                public event PropertyChangedEventHandler PropertyChanged;
    
                private string firstName;
                public string FirstName
                {
                    get { return firstName; }
                    set
                    {
                        if (firstName != value)
                        {
                            firstName = value;
                            if (PropertyChanged != null)
                            {
                                PropertyChanged(this, new PropertyChangedEventArgs("FirstName"));
                            }
                        }
                    }
                }
            }
    
            public class View1
            {
                public void MyPropertyChangedEventHandler(object source, PropertyChangedEventArgs arg)
                {
                    Console.WriteLine("Listener 1: Changed Property: {0}", arg.PropertyName);
                    string newValue = ((Model) source).FirstName;
                    Console.WriteLine("Listener 1: Changed Property Value: {0}", newValue);
                }
            }
    
            public class View2
            {
                public void MyPropertyChangedEventHandler(object source, PropertyChangedEventArgs arg)
                {
                    Console.WriteLine("Listener 2: Changed Property: {0}", arg.PropertyName);
                    string newValue = ((Model)source).FirstName;
                    Console.WriteLine("Listener 2: Changed Property Value: {0}", newValue);
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.