【发布时间】:2011-04-25 21:50:31
【问题描述】:
我在 XtratreeList(DevExress) 的 bindingList 中有一些属性,其中子节点需要显示 parentnode'e 属性。我有以下代码。
public abstract class ClassBase : INotifyPropertyChanged
{
protected static int initialId = 0;
private int id;
private int parentID;
private string productName;
private string productType;
private string colorProductType;
private void RaisePropertyChanged(string propertyName)
{
if ( PropertyChanged != null )
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public int ID
{
get { return id; }
set
{
if ( id == value )
return;
id = value;
RaisePropertyChanged("ID");
}
}
public int ParentID
{
get { return parentID; }
set
{
if ( parentID == value )
return;
parentID = value;
RaisePropertyChanged("ParentID");
}
}
public string ProductName
{
get { return productName; }
set
{
if ( productName == value )
return;
productName = value;
RaisePropertyChanged("ProductName");
}
}
public string ProductType
{
get { return productType; }
set
{
if ( productType == value )
return;
productType = value;
RaisePropertyChanged("ProductType");
RaisePropertyChanged("ColorProductType");
}
}
public string ColorProductType
{
get { return colorProductType ; }
set
{
if (colorProductType == value)
return;
colorProductType = value;
RaisePropertyChanged("ColorProductType");
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}`
我的要求是在ProductType 属性更改时更改ColorProductType 属性,基本上ProductType 是父节点属性,ColorProductType - 子节点属性。所以在改变父母的财产时,孩子的财产也需要改变。我将这两个属性都绑定到 2 个文本框。所以改变父道具应该改变两个文本框,但反之亦然。父级内的RaisePropertyChanged("ColorProductType"); 不起作用,colorproducttype 为空,这是什么问题?
【问题讨论】: