Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF Graph: How to get bounds of PlotArea and axes

Solved!
Go to solution

I can't find any explicit methods to get bounds of PlotArea and axes.

 

Please let me know of workarounds if available. Actually a post says how to get bounds of PlotArea by using RangeCursor. Is there alternative way for Axes?

 

The below picture shows what I did in WinForms with HitTest and GetBounds methods. I would like to draw adorners on WPF Graph.

 

 

WF HitTest.png

0 Kudos
Message 1 of 5
(4,606 Views)

The graph and its parts follow the WPF idiom of avoiding explicit bounds and positions for its parts, relying instead on the standard layout mechanism to position content based on size.

 

Depending on what you are trying to accomplish, different workarounds may be appropriate. Do you just want to show an outline around the different parts, or do you expect to move and reposition elements (based on the drag handles in your Windows Forms screenshot)?

~ Paul H
0 Kudos
Message 2 of 5
(4,588 Views)
Thanks for kind e

Here I just want to show outlines of the parts.
0 Kudos
Message 3 of 5
(4,582 Views)
Solution
Accepted by topic author diluculo

I've attached a code example that showing adorners around the plot area and scales.

 

Note that this relies on implementation details of the current release of the WPF controls for the scale adorners, as it was more efficient than incrementally hit testing points within the graph using the GetScaleAt method. We intentionally left many of the underlying primitive types with minimal documentation, as we have changed them in the past and may change them again in the future. Although these exact members may be removed in a later release, we do plan to provide equivalent functionality and stabilize the primitive API over time.

~ Paul H
0 Kudos
Message 4 of 5
(4,565 Views)

Great. Many thanks.

 

I updated the MeasurementStudio to its latest version and copied your code and finally I can show adorners for plotarea and axes.

 

 

WF Graph Adorners.png

0 Kudos
Message 5 of 5
(4,554 Views)