Minor ViewModelBase modification

Nov 5, 2010 at 12:51 PM

Hello,

it would be very helpful, if you could change the viewmodel base classes to something like below to allow overriding the event handling

(it would not break existing code):

   public abstract class ViewModelBase
 : INotifyPropertyChanged
    {

#region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected void NotifyPropertyChanged<T>(Expression<Func<T>> propertySelector)
        {
            Guard.ArgumentNotNull(propertySelector, "propertySelector");
            OnPropertyChanged(thisnew PropertyChangedEventArgs(PropertyChangedExtensions.GetPropertyName(propertySelector))); // CHANGE
        }

#endregion

// NEW
        protected virtual void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(sender, e);
            }
        }
    }

thanks!

please keep up the good work!
Coordinator
Nov 5, 2010 at 8:14 PM

Thanks.. and ya, I suppose I can do this - though I think I should forgo the sender parameter on OnPropertyChanged because it will/should always be "this". 

Cheers,
Rishi