Property Change event 를 작성하지 않아도 이 이벤트가 fire될 수 있도록 한다. :)
[Nuget package 설치 전]
public string InitialQty { get { return _initialQty; } set { if (value != _initialQty) { _initialQty = value; base.RaisePropertyChanged(m => m.InitialQty); } } }
[Nuget package 설치 후]
public string InitialQty { get; set;}
BaseViewmodel에 AddINotifyPropertyChangedInterface attribute를 추가한다.
BaseViewmodel를 상속받아 Viewmodel을 작성하면 된다. ^^
/// <summary> /// A base view model that fires Property Changed events as needed /// </summary> [AddINotifyPropertyChangedInterface] public class BaseViewModel : INotifyPropertyChanged { /// <summary> /// The event that is fired when any child property changes its value /// </summary> public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { }; /// <summary> /// Call this to fire a <see cref="PropertyChanged"/> event /// </summary> /// <param name="name"></param> public void OnPropertyChanged(string name) { PropertyChanged(this, new PropertyChangedEventArgs(name)); } }
public class MainWindowViewmodel : BaseViewModel {