我正在尝试在单格顿类中实现 INotifyPropertyChanged。
这是我的代码:
公共类PLC:INotifyPropertyChanged {
private static plc instance; public plc() { } public static plc Instance { get { if (instance == null) { instance = new plc(); } return instance; } set { instance = value; } } private static string _plcIp{get; set;} public string plcIp { get { return _plcIp; OnPropertyChanged(); } set { _plcIp = value; } } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged([CallerMemberName]string propertyName = null) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
我收到错误无法访问的代码被删除,当然 NotifyPropertyChange 不起作用