Zoom for WP7 app

4
我正在寻找一个能够使用手指缩放的WP7应用程序控件。我在CodePlex上看到了类似DeepZoomContainer的内容,但它并不完美。你有什么好的建议吗?我只需要通过缩放将其放大到150%。谢谢!
2个回答

5

谢谢Mick,但这会稍微破坏我的布局。我使用了更简单的方法。

我使用了Silverlight Toolkit for WP7并在我的网格上添加了pinch GetureListener手势。

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

在事件中编写代码

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();
    }

出现了错误:“无法解析指定对象上的GridScaling.ScaleX目标属性。” - Jonny
1
你需要将缩放对象添加到网格中 <Grid.RenderTransform> <ScaleTransform x:Name="GridScaling" ScaleX="1" ScaleY="1" /> </Grid.RenderTransform> - Lukasz Madon


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接