Last active
November 30, 2020 09:08
-
-
Save runceel/fd7cf1b955979121ca1c351daccb674c 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
class BindableBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected bool SetProperty<T>(ref T field, T value, [CallerMemberName]string propertyName = null) | |
{ | |
Debug.WriteLine("PropertyChangedが {GetType().Name} で呼ばれました。"); | |
field = value; | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} | |
class MyViewModel : BindableBase | |
{ | |
private string _name; | |
public string Name | |
{ | |
get => _name; | |
set | |
{ | |
Debug.WriteLine("set_Name が {GetType().Name} で呼ばれました。"); | |
SetProperty(ref _name, value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment