The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

Pinch Zoom and pan RRS feed

  • Question

  • Hi,

    i've a wide canvas (maybe 5 o 6 time wider and higher than the phone screen) and and i've to manege pan and pinch zoom. here is my xaml:

                    <Canvas x:Name="MapCanvas" Style="{StaticResource MapCanvasStyle}">
                                <ScaleTransform  />
                                <TranslateTransform />

    As you can see i have a TransformGroup instead of a CompositeTransform due to some pan problems occuring when i start a manipulation and zoom isn't .

    Mi code behind is:

                TransformGroup Transform = (TransformGroup)(OperatingCanvas.RenderTransform);
                ScaleTransform ScaleT = Transform.Children[0] as ScaleTransform;
                TranslateTransform TranslationT = Transform.Children[1] as TranslateTransform;
                if (Scale != 1)
                    double oldS = ScaleT.ScaleX;
                    ScaleT.CenterX = (From.X + TranslateX) * oldS; //This line
                    ScaleT.CenterY = (From.Y + TranslateX) * oldS;
                    ScaleT.ScaleX *= Scale;
                    ScaleT.ScaleY *= Scale;
                TranslationT.X += TranslateX;
                TranslationT.Y += TranslateY;

    everything seems to work well if i try to pinch zoom from a point near to the origin (the canvas is scaled with the correct center and in the correct direction). But, when i  fire the event from a point far from the origin, the zoom is applied using a wrong center and a wrong direction (both enlargementsandreductionsseem to have the point (0,0)as origin).

    I worked to this problem for days, and i'm pretty sure there is a logic problem in ScaleCenter setting. Can you help me?

    • Moved by Jamles Hez Monday, March 23, 2015 5:58 AM
    Monday, March 23, 2015 12:28 AM

All replies

  • Hi Cristiano,

    Could you share communities a minimum repro for the issue which could be easier for us to know the issue.

    I will move to Windows Phone forum for a better support :)


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 23, 2015 5:58 AM