INotifyPropertyChanged ์ธํฐํ์ด์ค์ PropertyChanged ์ด๋ฒคํธ ์ฐ์๋ ๋ถ ์์ผ์ ๊ฐ์?
์ ๋ ๊ฐ๋ฐํ ๋ ์์ฃผ ์ฐ๋ ํธ์ด๋ผ ์ฌ๋ ค๋ด
๋๋ค.
PropertyChangedBase๋ MVVM Framework์ค Caliburn.Micro๋ฅผ ์ฌ์ฉํ์์ต๋๋ค.
public class MainWindowViewModel : PropertyChangedBase
{
private string _strTest;
public string StrTest
{
get => _strTest;
set => Set(ref _strTest, value);
}
private int _intTest;
public int IntTest
{
get => _intTest;
set => Set(ref _intTest, value);
}
public MainWindowViewModel()
{
this.PropertyChanged += MainWindowViewModel_PropertyChanged;
}
private void MainWindowViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(StrTest):
if (!string.IsNullOrEmpty(StrTest))
{
//TODO:
}
break;
case nameof(IntTest):
if (IntTest > 0)
{
//TODO:
}
break;
default:
break;
}
}
}