Created
February 17, 2019 00:57
-
-
Save boronology/f9a980bc27205d7488899cdc600f2fad to your computer and use it in GitHub Desktop.
WPF定番コード集その2。ViewModelBase
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; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace TemplateApp.ViewModel | |
{ | |
public class ViewModelBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
//C#5.0以降で使用可能。CallerMemberNameによりコンパイル時に呼び出し元の名前が埋め込まれる | |
protected void OnPropertyChanged([CallerMemberName] string propertyName = "") | |
{ | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment