Last active
June 25, 2016 05:20
-
-
Save nicolasparada/4499f39b9868b6b9f2e8f85207fcb3ec to your computer and use it in GitHub Desktop.
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 Acme | |
{ | |
public abstract class BindableBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected virtual void SetProperty<T>(ref T property, T value, [CallerMemberName] string propertyName = null) | |
{ | |
if (Equals(property, value)) return; | |
property = value; | |
RaisePropertyChanged(propertyName); | |
} | |
protected virtual void RaisePropertyChanged([CallerMemberName]string propertyName = null) | |
{ | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment