使用带有CompositeDataSource的MVVM显示Chartplotter

时间:2017-01-23 11:50:09

标签: c# wpf mvvm plot dynamic-data-display

我按照this链接绑定数据进行查看。但是我无法使用CompositeDataSource 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]));

任何人都可以建议什么是更好的方法呢?

1 个答案:

答案 0 :(得分:0)

CompositeDataSource复制到绑定变量就可以了。