How to center whole diagram but also one part

I want to center whole diagram center the screen but i find the Diagram.Panel.CenterPart only allow one part to center,How can i do it?

You probably want to set the Diagram.HorizontalContentAlignment and VerticalContentAlignment properties to “Center”.

in the nomal time i want the diagram run at Strech…but i will center whole diagram when i click a button…and then it will run at Strech.

Ha!

I do it by code below:
// i click a button to center whole diagram by set HContentAlignment and VContentAlignment Center
// and add the dia.LaoutCompleted
btn.Click += (obj, ee) => {
dia.StartTransaction("hello");
dia.LayoutCompleted += new EventHandler(dia_LayoutCompleted);
dia.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
dia.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
dia.CommitTransaction("hello");
};
// in the event layoutcompleted a reset the H and V Stretch...
void dia_LayoutCompleted(object sender, DiagramEventArgs e)
{
dia.LayoutCompleted-=new EventHandler(dia_LayoutCompleted);
dia.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
dia.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
}
Is there any better method????

DiagramPanel panel = myDiagram.Panel;
Rect b = panel.DiagramBounds;
Rect v = panel.ViewportBounds;
panel.Position = new Point(b.X+b.Width/2-v.Width/2, b.Y+b.Height/2-v.Height/2);

thanks walter.it’s run ok!!