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;
}
}
}