SetScaleAndPosition with new scale

When I use the method SetScaleAndPosition on DiagramPanel with scale that is not the current scale the panel does not set the position as expected. If we run SetScaleAndPosition again with the same parameters after the scale has been set I then get the expected result.

I think it’s due to the fact the ScrollViewer cannot scroll to the actual position until we are in the final scale.

I don’t have repro demo but I can make one if it is necessary.

Thank you,

Does it work if there’s no scroll animation?

What are the values of Diagram.HorizontalContentAlignment, VerticalContentAlignment, Stretch, and any Initial… properties that you have set, or any other DiagramPanel properties?

We have both horizontal and vertical content alignment set to Stretch. We did not set any initial property.
This is the Diagram declaration:

                <go:Diagram x:Name="Diagram" BorderBrush="Black" BorderThickness="2"

                            NodeTemplateDictionary="{StaticResource NodeTemplateDictionary}"

                            LinkTemplateDictionary="{StaticResource LinkTemplateDictionary}"

                            HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"




I was unable in my initial attempt yesterday to reproduce the problem. Is animation required?

It’s odd that this would be a problem, because the first thing the SetScaleAndPosition method does is set the DiagramPanel.Scale and .Position properties to their new/final values.
The animations then work their way from the old values to end up at their new ones.

However it is possible and anticipated that the final values for those two properties are not the same as what were requested in the arguments.

Yes, I think animation is required because of the fact that you change both the scale and position properties concurrently on the same timeline - even though the Position property is depends on Scale.
I will try to create a StoryBoard that first change the scale and only then change the position - I’ll see how it goes.