Created
May 22, 2012 15:59
-
-
Save timheuer/2769949 to your computer and use it in GitHub Desktop.
Base View Model (simple)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
namespace App1 | |
{ | |
public class ViewModelBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected void SetValue<T>(ref T storage, T value, [CallerMemberName]string propertyName = null) | |
{ | |
if (object.Equals(storage, value)) { return; } | |
storage = value; | |
RaisePropertyChanged(propertyName); | |
} | |
void RaisePropertyChanged(string propertyName) | |
{ | |
if (PropertyChanged != null) | |
{ | |
PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment