Created
May 11, 2016 22:12
-
-
Save sidwarkd/4e06afeae798bb758aed5c3952fa49e2 to your computer and use it in GitHub Desktop.
Observable Class for UWP Data Binding
This file contains hidden or 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
public class Observable : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected void Changed([CallerMemberName]string propertyName = null) | |
{ | |
var handler = PropertyChanged; | |
if (handler != null) | |
{ | |
handler(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} | |
protected void SetProperty<T>(ref T field, T val, [CallerMemberName]string propertyName = null) | |
{ | |
if (object.Equals(field, val)) return; | |
field = val; | |
Changed(propertyName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment