Get the Diagram Boundaries

Hi Walter,

I have a scenario like i have to open a diagram from the XML file.
So when i am opening a Goxam diagram from the xml file,
i have to scale the diagram first and then i have to show the diagram.
For that i have some formulas to calculate scale and that works well.

But the problem as of now, i could able to get the diagram’s height and width from the Diagram.LayoutCompleted event only.
And after that based on the diagram’s height and width and Viewport height and width, i am scaling the diagram.

So at this case, what is happening is that, diagram is shown with the scale what was previously set and then re-scaling to the new one.

I dont want the previous scaled one to be shown, i want only the new re-scaled diagram to be shown.

So is there a way to get the Diagram boundaries before it gets displayed in the Panel rather than getting in Layout Completed event.

Thanks in advance.

Well, you need to wait until layouts are completed before you can know how big the area is that the diagram covers. Since you are loading a diagram you probably want to check in the Diagram.InitialLayoutCompleted event, rather than after each transaction/layout.

But if you do want to do it after each transaction, perhaps you don’t need to define an event handler at all – can you just set DiagramPanel.Stretch to Uniform? GoXam for WPF 2.2.4

With DiagramPanel.Stretch to Uniform, i could able to achieve ZoomtoFit, but i have other i have to do Zoom to height.

For that i tried with DiagramPanel.Stretch to UniformtoFill, it doesnot work with all the diagrams. Thats the reason i am calculating scale.

OK, well then, just set the myDiagram.Panel.Scale and myDiagram.Panel.Position the way that you want.

Remember that the DiagramPanel.Position may be limited by the diagram bounds and viewport.