Skip to content

Instantly share code, notes, and snippets.

@nicolasparada
Last active June 25, 2016 05:20
Show Gist options
  • Save nicolasparada/4499f39b9868b6b9f2e8f85207fcb3ec to your computer and use it in GitHub Desktop.
Save nicolasparada/4499f39b9868b6b9f2e8f85207fcb3ec to your computer and use it in GitHub Desktop.
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