Hi Walter,

I'm trying to use a slider to implement the zoom feature inherent by using ctrl-mousewheel.
Here is the method I'm using from a value changed event
private void OnZoomLevelChanged(Diagram diagram)
diagram.Panel.SetScaleAndPosition(ZoomLevel, diagram.Panel.Position, 0, null ); }
It almost works
The problem is it doesn't seem to maintain the panning like the mousewheel does. Is there a way I can factor that in?

A Slider by itself doesn’t specify any particular point in the Diagram, so you’ll need to calculate the point (in model coordinates) that you want to pass to that SetScaleAndPosition method.

Using the current Diagram.Panel.Position, as you are now, will tend to keep the top-left point the same. Although that depends on the size of the Diagram.Panel properties: DiagramBounds, HorizontalContentAlignment, and VerticalContentAlignment.

Hi Walter,

Thanks for yuor reply. I'm only using the slider for zoom level, not position. The zoom (scaling) works fine. The problem I'm having is that using the current Diagram.Panel.Position in SetScaleAndPosition doesn't seem to keep the panel in the current position. Is this a bug? I guess my question is "how is the mouse wheel doing it?"

Actually, your code is keeping the same Diagram.Panel.Position.

What the mouse wheel is doing is calculating the desired DiagramPanel.Position so that the mouse point stays at the same model point.

My question for you is: what point in model coordinates do you want to keep the same after changing the DiagramPanel.Scale? This is not a mouse event, so there’s no mouse pointer position from which to get the model coordinates.

If you don’t like what you are doing by keeping the DiagramPanel.Position, you could try using the center point of the DiagramPanel.ViewportBounds.

Hi Walter,

my question is how to maintain the panning while zooming?
If I pan the diagram (using the panning tool), is there a way to get the upper left hand corner of the viewing bounds and prevent it from panning back to the upper left hand corner. From a users perspective it would be great while you are zooming to maintain the translation of the diagram, but not sure how to do it. Here is my settings on the diagram
<go:Diagram x:Name="myDiagram" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" InitialStretch="Uniform" InitialPosition="0,0" AllowDrop="True" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Model="{Binding LatDataModel}" dragDrop:RadDragAndDropManager.AllowDrop="True" LatMvvmBridge:Diagram.DropInfo="{Binding DropInfo}" LatMvvmBridge:Diagram.DropQuery="{Binding DropQuery}" NodeTemplate="{StaticResource nodeTemplate}" LinkTemplate="{StaticResource linkTemplate}" Background="{StaticResource Brush.Gray.MediumDark}" InitialDiagramBoundsSpot="MiddleTop" InitialPanelSpot="MiddleTop" Template="{StaticResource DiagramControlTemplate}" >

Are you asking a completely different question, about the PanningTool?

About zooming, do you know about the DiagramPanel.ZoomPoint property? That might help when changing the DiagramPanel.Scale. But note that ZoomPoint is not used by the SetScaleAndPosition method, since that method takes the desired DiagramPanel.Position as an argument.