locked
Do not scale ScrollViewer children, that are inside Canvas

    Question

  • I have a ScrollViewer which has a Canvas inside it. To make this construction support panning, I'm setting MinZoomFactor and MaxZoomFactor to 4.

    Is it possible to NOT apply scale on elements that are added later at runtime to the canvas? How can I achieve it? LayoutTransform is not available in WinRT, and I didn't manage to apply RenderTransform.Inverse to canvas child elements to compensate scale.

    Thanks.

    Thursday, April 09, 2015 8:44 AM

Answers

  • You have two options:

    1) Lay two canvases on top of each other.  Put scaling objects in one, non-scaling objects in the other. Scale only the one canvas.

    2) Apply a ScaleTransform to objects which you don't want scaled.  The ScaleTransform's value is databinded to the ScrollViewer ZoomFactor in an inverse proportion.  The daabinding must go through a converter to be inverted (literally 1/ZoomFactor).


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by philous Saturday, April 11, 2015 2:36 PM
    Thursday, April 09, 2015 1:01 PM
    Moderator