Zoom to fit

Hello,
I’m having hard time figure out how to implement Zoom To Fit function in the new GoXam.
I use Center for both horizontal and vertical content alignment to allow the user to freely move the diagram without the control keep center it for him.

I use this code to calculate the scale to see all the diagram:

private void ZoomToFitImpl() {

double heightRatio = diagram.Panel.ActualHeight / diagram.Panel.DiagramBounds.Height;

double widthRadio = diagram.Panel.ActualWidth / diagram.Panel.DiagramBounds.Width;

double ratioToUSe = Math.Min(heightRatio, widthRadio);

ZoomFactor = ratioToUSe;

}

The main problem is that I can't get it to scale the diagram on the initial display. Later invokation of this method scale the diagram right.

I still need to scroll the diagam I think but I didn't implement it yet.

Help will be great,

Thank you,

Ido.

Perhaps you are setting Diagram.Panel.Scale too early, when the diagram hasn’t had time to be realized and the windows haven’t had the chance to be fully laid out. Try doing so in a Diagram.InitialLayoutCompleted event handler.

I am looking for the same feature, but some information is missing:

  1. On what element the ContentAlignement are set ?
  2. On what element the ZoomFactor is set ?

Thanks

HorizontalContentAlignment and VerticalContentAlignment are properties on Diagram.

DiagramPanel (i.e. myDiagram.Panel) has the Position and Scale properties.

FYI we will be adding a ZoomToFit method in the next release.