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? –
,你创建对象并对其进行初始化代码 –