0

I am creating a ChartPlotter and using CursorCoordinateGraph i am able to get the X coordinate on MouseLeftButtonDown event.

    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;
    }

Is there a way to draw a vertical line on that xValue coordinate? I am a bit lost in line graphs, lines, vertical lines..

Olaru Mircea
  • 2,570
  • 26
  • 49
  • 1
    You should add the solution as an answer, which you can accept in 2 days time. –  May 20 '15 at 14:23

1 Answers1

1

Add this lines of code after the computation of xValue in OnMouseLeftButtonDown.

VerticalLine vl = new VerticalLine();
vl.Value = xValue;

I assume you want to add that line to the aforementioned plottter:

firstPlotter.Children.Add(vl);

You can use the same approach for HorizontalLine.