Skip to content

Instantly share code, notes, and snippets.

@JuanKRuiz
Last active January 18, 2016 01:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save JuanKRuiz/b686ca389077a120c60b to your computer and use it in GitHub Desktop.
BindableBase class used in WinRT App development
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace System.ComponentModel
{
public class BindableBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public bool SetProperty<T>(ref T propertyBackStore, T newValue, [CallerMemberName] string propertyName = "")
{
if (Equals(propertyBackStore, newValue))
return false;
propertyBackStore = newValue;
if (PropertyChanged != null)
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName)
);
return true;
}
public BindableBase()
{
}
public BindableBase(PropertyChangedEventHandler propertyChanged)
{
PropertyChanged = propertyChanged;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment