我有一个类 Cell 看起来像这样:
public Color color{get { return colorr; }
set { colorr = value;
if (this.PropertyChanged != null){
this.PropertyChanged(this, new PropertyChangedEventArgs("color"));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
我在 viewport3D 中添加了很多“单元”来生成多维数据集。随着时间的推移,细胞的颜色会发生变化。所以我的问题是 - 我可以将单元格的颜色绑定到代码中的实心画笔,而不是每次更改时都重新绘制单元格吗?
我有这样的东西,但它不会工作。
Binding b = new Binding();
b.Source = cell.color;
SolidColorBrush solidBrush = new SolidColorBrush();
BindingOperations.SetBinding(solidBrush, SolidColorBrush.ColorProperty, b);
Material material = new DiffuseMaterial(solidBrush);
我现在假设solidBrush 的颜色会在单元格颜色发生变化时发生变化,因此viewport3D 上立方体的颜色也会发生变化。但它没有。
谢谢 - 大卫