Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zoom for WP7 app

I'm lookin for a control for a WP7 app that allows zooming by pinch. I saw on codeplex smth like DeepZoomContener but is doesn't do well. Any ideas? I just need zoom to 150% by pinching that's all.

Regards.

like image 965
Lukasz Madon Avatar asked Feb 25 '23 12:02

Lukasz Madon


1 Answers

Thx Mick but this messed up with my layout a bit. I did something more simple.

I use the Silverlight Toolkit for WP7 and add the pinch GetureListener to my grid

    <toolkit:GestureService.GestureListener>
        <toolkit:GestureListener PinchDelta="GestureListener_PinchDelta" />
    </toolkit:GestureService.GestureListener>

and code in event

private void GestureListener_PinchDelta(object sender, PinchGestureEventArgs e)
    {
        if (e.DistanceRatio < 1.0 || e.DistanceRatio > 1.4)
        {
            return;
        }
        // Create the animation for pinch
        Storyboard storyboard = new Storyboard();
        DoubleAnimation pinchXAnimation = new DoubleAnimation();
        pinchXAnimation.To = e.DistanceRatio;
        pinchXAnimation.Duration = TimeSpan.FromSeconds(0.3);
        storyboard.Children.Add(pinchXAnimation);
        Storyboard.SetTargetProperty(pinchXAnimation, new PropertyPath("GridScaling.ScaleX"));
        Storyboard.SetTarget(pinchXAnimation, GridScaling);

        DoubleAnimation pinchYAnimation = new DoubleAnimation();
        pinchYAnimation.To = e.DistanceRatio;
        pinchYAnimation.Duration = TimeSpan.FromSeconds(0.3);
        storyboard.Children.Add(pinchYAnimation);
        Storyboard.SetTargetProperty(pinchYAnimation, new PropertyPath("GridScaling.ScaleY"));
        Storyboard.SetTarget(pinchYAnimation, GridScaling);

        storyboard.Begin();
    }
like image 87
Lukasz Madon Avatar answered Mar 07 '23 03:03

Lukasz Madon