반응형
public class Model : INotifyPropertyChanged
{
private string someText;
public string SomeText
{
get => someText;
set
{
if (someText == value) return;
someText = value;
NotifyPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged([CallerMemberName] string name = null)
{
if (!String.IsNullOrEmpty(name))
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
}
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { };
public void OnPropertyChanged(string name)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
public class Model2 : ViewModelBase
{
public string SomeText { get; set; }
}
[AddINotifyPropertyChangedInterface]
public class Model3
{
public string SomeText { get; set; }
}
반응형
'[====== Development ======] > C#' 카테고리의 다른 글
WPF Visibility 속성을 Radiobutton 의 IsChedched 속성과 바인딩하기 (0) | 2021.10.26 |
---|---|
.Net Core Entity Framework Db First Sqlite (0) | 2021.10.24 |
[WPF] naming convention - UIElement name Prefix (0) | 2021.10.19 |
[C#] Exception으로 인한 죽는것 방지 (0) | 2021.08.13 |
[C#] 중복 실행 방지 (0) | 2021.08.13 |