Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

wpf graph detect mouse on axis

Solved!
Go to solution

How do I get events for mouse interaction with axes? With WF graphs I used following code:

 

switch (graph.HitTest(e.X, e.Y))
{
case XYGraphHitTestInfo.XAxis:

etc...

0 Kudos
Message 1 of 3
(5,942 Views)
Solution
Accepted by topic author eugenem

You can use the GetScaleAt method to detect a scale at a given mouse position (GetChildrenAtPoint should return scales as well, but this is not working in the current release).

 

Here is an example of using GetScaleAt in the MouseLeftButtonDown event on a graph (note that the graph needs to have a hit-testable background like Transparent, instead of the default value of null, or else only clicks exactly on visuals in the scale will work):

 

    private void OnGraphMouseLeftButtonDown( object sender, MouseButtonEventArgs e ) {
        Point screenPosition = e.GetPosition( graph );
        var scale = graph.GetScaleAt( screenPosition );
        Console.WriteLine( "Scale at {0}? {1}", screenPosition, scale == null ? "no" : "yes" );
    }

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

Just wanted to let you know this issue was fixed in the Measurement Studio 2013 release.

~ Paul H
0 Kudos
Message 3 of 3
(5,790 Views)