Alex Rivera | Logout

NotifyPropertyChanged event where event args contain the old value

Asked 2011-10-06T17:00:39.940
22

Is there an INotifyPropertyChanged-like interface where the event args contains the old value of the property being changed, or do I have to extend that interface to create one?

For example:

    public String ProcessDescription
    {
        get { return _ProcessDescription; }
        set
        {
            if( value != ProcessDescription )
            {
                String oldValue = _ProcessDescription;
                _ProcessDescription = value;
                InvokePropertyChanged("ProcessDescription", oldvalue);
            }
        }
    }

    InvokePropertyChanged(String PropertyName, OldValue)
    {
         this.PropertyChanged( new ExtendedPropertyChangedEventArgs(PropertyName, OldValue) );
    }

I would also settle for a PropertyChanging-like event which provides this information, whether or not it supports e.Cancel.

Edit
Report

1 Answer

1

If you only want to old value you can invoke the event before changing the property's value. But that would be a departure of how this event is normally used, so I would create a dedicated interface and args for it.

answered 2011-10-06T17:05:36.607

Your Answer