我正在创建一个ChartPlotter,并使用CursorCoordinateGraph,我能够在MouseLeftButtonDown事件上获得X坐标。
private CursorCoordinateGraph mouseTrack;
private void OnLoaded(object sender, RoutedEventArgs e)
{
mouseTrack = new CursorCoordinateGraph();
firstPlotter.Children.Add(mouseTrack);
}
private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Point mousePos = mouseTrack.Position;
var transform = firstPlotter.Viewport.Transform;
Point mousePosInData = mousePos.ScreenToData(transform);
double xValue = mousePosInData.X;
}
有没有办法在xValue坐标上画一条垂直线?我有点迷线形图,直线,垂直线…
在OnMouseLeftButtonDown中计算xValue后添加以下代码行:
VerticalLine vl = new VerticalLine();
vl.Value = xValue;
我假设您想将这行添加到前面提到的绘图器中:
firstPlotter.Children.Add(vl);
您可以对HorizontalLine使用相同的方法。