Skip to content

Instantly share code, notes, and snippets.

@boronology
Created February 17, 2019 00:57
Show Gist options
  • Save boronology/f9a980bc27205d7488899cdc600f2fad to your computer and use it in GitHub Desktop.
Save boronology/f9a980bc27205d7488899cdc600f2fad to your computer and use it in GitHub Desktop.
WPF定番コード集その2。ViewModelBase
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