【发布时间】:2016-08-11 14:39:55
【问题描述】:
我有 5 列的 DataGrid。某些列的值取决于其他列。如何创建这种依赖关系?我试图实现这个填充数据网格的结构。但是在编辑其他单元格的情况下没有更新。
public class ColorItem
{
// Constructor
/*
* ColorItem constructor
* Params: color name, color
*/
public ColorItem(string color_name, Color color)
{
ItemName = color_name;
RChanel = color.R;
GChanel = color.G;
BChanel = color.B;
}
// Item name
public string ItemName { get; set; }
// Item color (calculated item)
public Brush ItemColor { get { return new SolidColorBrush(Color.FromRgb(RChanel, GChanel, BChanel)); } }
// Item r chanel
public byte RChanel { get; set; }
// Item g chanel
public byte GChanel { get; set; }
// Item b chanel
public byte BChanel { get; set; }
}
【问题讨论】:
-
你问的是bindings吗?
-
我使用绑定来创建这样的网格数据。但是我不明白,为什么在编辑例如RChanel的情况下,ItemColor没有更新
-
ItemColor没有实现INotifyPropertyChanged。 -
但这取决于其他属性。