【Tips】建立OnPropertyChanged。其中的方法簽章若沒有寫入,則預設為呼叫的成員名稱


using System.ComponentModel;
using System.Runtime.CompilerServices;
public class MyDataContext : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        //Console.WriteLine($"MyDataContext:OnPropertyChanged__{propertyName}");
    }
}
#wpf






你可能感興趣的文章

初見狀態管理工具 Vuex (4) - Modules

初見狀態管理工具 Vuex (4) - Modules

Unlocking the Secrets: How to Farm Diablo 4 Gold and Rare Items Like a Pro

Unlocking the Secrets: How to Farm Diablo 4 Gold and Rare Items Like a Pro

W16_JavaScript 核心與物件導向_學習筆記整理

W16_JavaScript 核心與物件導向_學習筆記整理






留言討論