C# – How RaisePropertyChanged works in MVVM light

MVVM light provides an easy way of the strong typed RaisePropertyChanged with lambda. The following code shows how this can find the correct string for member of ViewModel.

public void RaisePropertyChanged<T>(Expression<Func<T>> property)
    PropertyChanged(this, new PropertyChangedEventArgs(property.GetMemberInfo().Name);

so you can use the following code safely.

public class ViewModel : ViewModelBase
    private string _name;

    public string ProductName;
    { get { return _name; }
          _name = value;
          RasePropertyChanged(() => ProductName);
This entry was posted in .NET, Programming and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s