我点击了此链接将数据绑定到视图。但是我无法使用复合数据源uisng MVVM显示结果。
pixelX = new double[grayScaleData.Length];
grayLevelY = new double[grayScaleData.Length];
for (int i = 0; i < grayScaleData.Length; i++)
{
pixelX[i] = i;
grayLevelY[i] = grayScaleData[i];
if (i >= (leftEdge + avgGrayoffset) && i <= (rightEdge - avgGrayoffset))
{
totalGrayScale += grayScaleData[i];
totalPixels++;
}
}
EnumerableDataSource<double> xSrc = new EnumerableDataSource<double>(pixelX);
xSrc.SetXMapping(x => x);
grayScaleDataSource = new EnumerableDataSource<double>(grayLevelY);
grayScaleDataSource.SetYMapping(y => y);
CompositeDataSource source= new CompositeDataSource(xSrc, grayScaleDataSource);
for (int i = 0; i < grayScaleData.Length; i++)
{
//here I am not able to convert a CompositeDataSource to a point source
// list.Add(new Point(??,??));
}
GrayScalePlotData = new ObservableDataSource<Point>(list);
只需使用Point
我就能看到一些随机情节
list.Add(new Point(pixelX[i], grayLevelY[i]));
谁能建议更好的方法是什么?
将CompositeDataSource
复制到绑定变量可以解决问题。