BindableBase class used in WinRT App development
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 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