简体   繁体   中英

What's behind INotifyPropertyChanged's PropertyChanged event handler? What is the message receiveing/processing mechanism?

We all've been using INotifyPropertyChanged . It allows the controls being developed to subscribe to the PropertyChanged events.

At the same time, the implementation of the interface is pretty simple and actually doesn't assume any explicit code for the PropertyChanged event handler. Here is a typical example of the implementation:

    public event PropertyChangedEventHandler PropertyChanged;

    public void OnPropertyChange(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

It seems that WPF itself assigns an event handler to the declared member " PropertyChanged ". So my question is what exactly WPF does with this member.

Maybe anybody could suggest a good article regarding the exact mechanisms behind INotifyPropertyChanged .

I saw that many people on SO have already asked some similar questions but I haven't found any explicit answer.

Thanks!

If you want to interactively explore what is going on with INotifyPropertyChanged, I highly recommend going to Microsoft's new Reference Source site. I have been using it extensively to learn what is going on behind the scenes in .NET.

Here is a starting point for you:

INotifyPropertyChanged (System)

You'll also see a INotifyPropertyChanged2 implementation in PresentationFramework that you'll probably want to look through.

I hope this is helpful!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM