我有一个程序可以读取文件并从文件内容创建大约1000个点(X,Y坐标)。我希望将这些点显示为网格上的小十字(基本上是一种图表)。
目前我在代码中执行此操作:
foreach (var measurement in collection)
{
createValueCross(measurement);
}
private void createValueCross(CGM_Measurement measurement)
{
// set color of line (green when within opt range)
var crossColor = measurement.Value < mvm.OptMaximum && measurement.Value > mvm.OptMinimum ? Colors.Green : Colors.Blue;
//create lines
Line horizontal = new Line();
Line vertical = new Line();
vertical.Stroke = horizontal.Stroke = new SolidColorBrush(crossColor);
vertical.StrokeThickness = horizontal.StrokeThickness = 1;
//get center coordinates
var x = measurement.Time.getXPosition();
x = x < 10 ? 10 : x;
var y = measurement.Value.getYPosition();
y = y < 10 ? 10 : y;
// set line start/endpoint +-2 pix from center
horizontal.X1 = x - 2;
horizontal.X2 = x + 2;
horizontal.Y1 = horizontal.Y2 = y;
vertical.Y1 = y - 2;
vertical.Y2 = y + 2;
vertical.X1 = vertical.X2 = x;
// draw lines on grid
chartDataGrid.Children.Add(horizontal);
chartDataGrid.Children.Add(vertical);
}
在XAML中有一个很好的方法吗?喜欢&#34; Polyline&#34;你可以在哪里指定一个点集合?