Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

[WPF]how to set cursor on the position I clicked on the graph?

Hello,

 

I used to do that in a winform project by use thefollowing function:

PlotAreaMouseDownCwgraph(short* Button, short* Shift, VARIANT* XPos, VARIANT* YPos)

 

But in a wpf graph, the PlotAreaMouseLeftButtonDown event seems not contain the xpos and ypos. I wrote the following code and got a wrong result:

 

        void m_Graph_PlotAreaMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (m_Graph.DefaultInteraction == GraphInteraction.None)
            {
                Point p = m_Graph.GetPlotAreaPosition(e);
                cursor.SetRelativePosition(p);
            }
        }

0 Kudos
Message 1 of 2
(5,620 Views)

The value returned by GetPlotAreaPosition is a screen value (the documentation is a bit confusing here; I have created a task to update it).


To use SetRelativePosition, you can convert the screen value to a relative value by calling the ScreenToRelative on the graph.


Or you can pass the value returned by GetPlotAreaPosition directly to the SetScreenPosition method on the cursor.

~ Paul H
0 Kudos
Message 2 of 2
(5,606 Views)