I have an issue that i think is related to the AutoScroll or ViewPortBounds properties.
Whenever I move a node AFTER zooming in or scolling, the diagram jumps to a new position which is quite irritating.
I have tried a number of things after reading a few posts.
A few things i have tried are:
- stopping auto scroll (Me.myDiagram.Panel.StopAutoScroll())
-handling template applied and setting autoscroll region to thickness of zero (Me.myDiagram.Panel.AutoScrollRegion = New Thickness(0))
-changing the zoom time which only makes it jump quicker (Me.myDiagram.Panel.ZoomTime = 0)
-setting a custom template for the diagram (Template="{StaticResource CustomAutoScroller}") then overriding ComputeAutoScrollPosition :
Protected Overrides Function ComputeAutoScrollPosition(viewPnt As System.Windows.Point) As System.Windows.Point Dim bounds = Me.DiagramBounds Dim view = Me.ViewportBounds Dim pos = MyBase.ComputeAutoScrollPosition(viewPnt) pos.X = Math.Max(Math.Min(pos.X, bounds.Right - view.Width), bounds.X) pos.Y = Math.Max(Math.Min(pos.Y, bounds.Bottom - view.Height), bounds.Y) Return pos End Function
Are you talking about when the user moves a node, rather than a programmatic change of node location? Is the diagram automatically scrolling to make the selected node visible? Can you reproduce the problem with any of the sample apps?
Are the diagram contents smaller than the diagram viewport and are the Diagram.Horizontal/VerticalContentAlignment properties not set to “Stretch”?
Are you sure about “autoscrolling” being the problem? Autoscrolling only happens during a user drag operation when the mouse is held (down) just inside the edge of the viewport.
Setting the …ContentAlignment=“Stretch” should get you what I think you want. That is what you can see happens in various samples. For example, in the Logic Circuit sample, manually moving a node within the viewport does not cause any scrolling. Moving a node outside of the viewport may cause the viewport to be scrolled if the whole viewport isn’t in use but could be.