2017-01-23 61 views
0

我跟着this鏈接來綁定數據以查看。但我無法使用CompositeDataSource顯示結果uisng MVVM。使用使用MVVM和CompositeDataSource顯示Chartplotter

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])); 

任何人都可以提出什麼更好的方式來做到這一點?

回答

0

CompositeDataSource複製到一個綁定變量做了訣竅。