0
我使用INotifyPropertyChanged
來通知班級,其中特定對象的變量發生任何變化時。即使在註冊後,屬性更改事件爲空
下面是類:
public class MyClass
{
public SecClass MyObj { get; set; }
//A few more variables
}
SecClass:
public class SecClass:INotifyPropertyChanged
{
private bool _noti= false;
public bool Noti
{
get { return _noti; }
set
{
_noti= value;
NotifyPropertyChanged("Noti");
}
}
//A few more variables
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
這裏我的功能,使活動報名:
public void Register()
{
MyObj.PropertyChanged += MyObj_PropertyChanged;
}
功能的工作原理,並登記已完成,但當涉及到更改它顯示爲Property Change
爲空(我猜somewhe重新註冊刪除,之前發生的變化,我怎麼能檢查)
顯示一些代碼,請在您註冊你的意思是像'Register'方法的事件處理程序 –
@ bash.d? –
,你創建對象並對其進行初始化代碼 –