0

I working on Charting of Wpf tool kit. I have x-axis as Freuency and Y-axis as Immediate Level. The graph is realtime graph.

I need to know the ordinates of a point where user has clicked.

Is there any event raised or any property where i can get the current mouse point ordinates or i need to calculate it at my own meaning there is no inbuilt way available.

Thanks in advance.

D J

D J
  • 6,908
  • 13
  • 43
  • 75

1 Answers1

0

I think this should help:

Private Sub GroupChart_MouseLeftButtonDown(sender As Object, e As System.Windows.Input.MouseButtonEventArgs) Handles GroupChart.MouseLeftButtonDown

    Dim SelectedIndex As Integer

    Dim element As DependencyObject = Mouse.DirectlyOver
    While (element IsNot Nothing And Not (TypeOf element Is ScatterDataPoint))
        element = VisualTreeHelper.GetParent(element)
    End While
    If Not IsNothing(element) Then
        Dim foundDataPoint As ScatterDataPoint = element
        Dim foundCanvas = VisualTreeHelper.GetParent(element)

        Dim ChildCount = VisualTreeHelper.GetChildrenCount(foundCanvas)

        For i = 0 To ChildCount - 1

            Dim CurrentContentPresenter = VisualTreeHelper.GetChild(foundCanvas, i)

            If Object.ReferenceEquals(foundDataPoint, CurrentContentPresenter) Then
                SelectedIndex = i
                Exit For
            End If

        Next

    End If

End Sub