C#引发PropertyChanged事件
示例
片段
public class Person : INotifyPropertyChanged
{
private string _address;
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public string Address
{
get { return _address; }
set
{
if (_address == value)
{
return;
}
_address = value;
OnPropertyChanged(nameof(Address));
}
}
}
...
var person = new Person();
person.PropertyChanged += (s,e) => Console.WriteLine(e.PropertyName);
person.Address = "123 Fake Street";控制台输出
地址
热门推荐
10 空军大学开学祝福语简短
11 中午生日家庭祝福语简短
12 婆媳结伴踏青祝福语简短
13 信件祝福语简短情话短句
14 新年稳重的祝福语简短
15 2026简短祝福语给老师
16 生日祝福语贺卡文字简短
17 姐姐生日霸气祝福语简短
18 春节祝福语简短英文高级