6
Vote

Implement [CallerMemberName] for RaisePropertyChanged

description

Hi it would be great to have a propertychanged call with the callermembername attribute for .net 4.5 applications

http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.callermembernameattribute.aspx
        protected virtual void RaiseThisChanged([CallerMemberName] string propertyName = "")
        {
            VerifyPropertyName(propertyName);

            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
But it would be better to name it to RaiseThisChanged or something because you wouldn't be able to use the normal RaisePropertyChanged("Property") call.

comments

PjlCodeplex wrote Mar 2, 2013 at 7:22 PM

I agree. ViewModelBase could also be extended with
    public bool Set<T>(ref T field, T value, [CallerMemberName] string propertyName = "")
    {
        return this.Set(propertyName, ref field, value);
    }

dbalboa wrote Mar 20, 2013 at 9:03 AM

+1. This is a great feature added to c# 5.0 that i would like to see implemented on this toolkit!

Havremunken wrote Jun 12, 2013 at 6:02 AM

+1 here. Apparently this is an efficient way to do things, please support. :)

lbugnion wrote Jun 12, 2013 at 6:57 AM

Hey there,

This is already implemented, i will publish with V4.2. Expect a preview on Codeplex very soon with other improvements.

cheers
Laurent