c# - 缩放 WP7 应用程序

标签 c# silverlight windows-phone-7

我正在寻找允许双指缩放的 WP7 应用程序控件。我在像 DeepZoomContener 这样的 codeplex smth 上看到过,但效果不佳。有任何想法吗?我只需要通过捏合即可缩放到 150%。

问候。

最佳答案

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

关于c# - 缩放 WP7 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4531806/

相关文章:

c# - 有没有办法重构 C# 独有的 switch 语句?

wpf - Silverlight 3 绑定(bind)到集合中的当前项

c# - 以异步方式刷新 Xamarin.Android 中的 AudioTrack

c# - Silverlight 到 WPF 转换器

silverlight - wp7 中后台代理的工作

c# - 如何在 Silverlight 中获取另一个时区的本地时间

c# - 用于显示独立存储中文件的数据绑定(bind)或 foreach

windows-phone-7 - WP7 工具包 : Gestures on ListBox - selected item

c# - 在上下文中找不到某些词,缺少引用,大脑即将爆炸?

c# - 在一个地方存储多个用户的数据