This project has moved. For the latest updates, please go here.

Intellisensed RaisePropertyChanged..

Jan 3, 2011 at 8:07 PM
Edited Jan 3, 2011 at 8:51 PM
public class MyViewModelBase : ViewModelBase

        protected string NameOf<T>(Expression<Func<T, object>> propertyExpression)
            return this.NameOf<T>(propertyExpression);

I'd like to implement this, but am unable to without modifying your code. I'm not fond of maintaining my own specialized source :(
(Error 8 The event 'GalaSoft.MvvmLight.ViewModelBase.PropertyChanged' can only appear on the left hand side of += or -= )

Suggestions? Could this be added to the toolkit? Is the performance hit not worth the convenience?

        protected void RaisePropertyChanged<T>(Expression<Func<T>> property) 
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
                handler(this, property.CreateChangeEventArgs());
    public static class PropertyExtensions 
        public static PropertyChangedEventArgs CreateChangeEventArgs<T>(this Expression<Func<T>> property) 
            var expression = property.Body as MemberExpression; 
            var member = expression.Member; 
            return new PropertyChangedEventArgs(member.Name); 
using this in the interim:
Jan 13, 2011 at 4:10 PM


Something similar is on the backlog for VNext.