Viewbox center zooming on Windows Phone

277 Views Asked by At

I have tried to make a viewbox zoom in on particular places with respect to the center of the pinch move. I can catch the event but I cannot seem to understand the different values.

In pinchmanipulation should I use pinchmanipulation.Current, or pinchmanipulation.origin?

and how do I calculate the precise middle such that it is not depended on the direction of my pinch move.

At the moment this is what I'm doing:

<Viewbox Stretch="UniformToFill" RenderTransformOrigin="{Binding Points}">


                <Viewbox.RenderTransform>
                    <CompositeTransform ScaleX="{Binding Map.deltaZoom}" ScaleY="{Binding Map.deltaZoom}" TranslateX="{Binding Map.TranslateX}" TranslateY="{Binding Map.TranslateY}"/>
                </Viewbox.RenderTransform>

                <View:PlayingMap/>
            </Viewbox>
            `

And the code where I do my manipulation:

    public void ZoomDelta(ManipulationDeltaEventArgs e)
    {

        FrameworkElement Element = (FrameworkElement)e.OriginalSource;
        Viewbox PlayingMap;

        if (Element is Viewbox)
        {
            PlayingMap = Element as Viewbox;
        }
        else
        {
            PlayingMap = FindParentOfType<Viewbox>(Element);
        }

        if (e.PinchManipulation != null)
        {
         //Place for code
         }
      }
0

There are 0 best solutions below