代码如下:public class DomainBase : INotifyPropertyChanged
{
private int _id;
public virtual int ID
{
get { return _id; }
set
{
if (value != this._id)
{
_id = value;
PropChanged("ID");
}
}
} public virtual event PropertyChangedEventHandler PropertyChanged;
public virtual void PropChanged(string fieldName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(fieldName));
}
}
} public class ItemValue : DomainBase
{
...
}当我把上面的ItemValue对象绑定到RadioButton后,在RadioButton由“选中”变成“没选中”会出现红色边框,围绕在RadioButton周围。如果把属性通知事件放在ItemValue里,如下:public class DomainBase
{
public virtual int ID { get; set; }
} public class ItemValue : DomainBase,INotifyPropertyChanged
{
private int _id;
public override int ID
{
get { return _id; }
set
{
if (value != this._id)
{
_id = value;
PropChanged("ID");
}
}
} public virtual event PropertyChangedEventHandler PropertyChanged;
public virtual void PropChanged(string fieldName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(fieldName));
}
}
}这个时候是正常的,RadioButton不会出现红色边框。为什么会出现这样的问题?
{
private int _id;
public virtual int ID
{
get { return _id; }
set
{
if (value != this._id)
{
_id = value;
PropChanged("ID");
}
}
} public virtual event PropertyChangedEventHandler PropertyChanged;
public virtual void PropChanged(string fieldName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(fieldName));
}
}
} public class ItemValue : DomainBase
{
...
}当我把上面的ItemValue对象绑定到RadioButton后,在RadioButton由“选中”变成“没选中”会出现红色边框,围绕在RadioButton周围。如果把属性通知事件放在ItemValue里,如下:public class DomainBase
{
public virtual int ID { get; set; }
} public class ItemValue : DomainBase,INotifyPropertyChanged
{
private int _id;
public override int ID
{
get { return _id; }
set
{
if (value != this._id)
{
_id = value;
PropChanged("ID");
}
}
} public virtual event PropertyChangedEventHandler PropertyChanged;
public virtual void PropChanged(string fieldName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(fieldName));
}
}
}这个时候是正常的,RadioButton不会出现红色边框。为什么会出现这样的问题?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货