在 Windows Phone 8 上平滑缩放和平移 [英] Smooth pinch-zooming and panning on Windows Phone 8

查看:27
本文介绍了在 Windows Phone 8 上平滑缩放和平移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过连接到 ManipulationDelta 和 ManipulationStarted 事件(在图像控件上),我设法实现了双指缩放和平移:

I've managed to implement pinch zooming and panning by hooking up to the ManipulationDelta and ManipulationStarted events (on an image control):

    private void image_OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
    {
        var transform = (CompositeTransform)image.RenderTransform;

        // pan
        transform.TranslateX = _translationX + e.CumulativeManipulation.Translation.X;
        transform.TranslateY = _translationY + e.CumulativeManipulation.Translation.Y;

        // zoom
        if (e.PinchManipulation != null)
        {
            transform.CenterX = e.PinchManipulation.Original.Center.X;
            transform.CenterY = e.PinchManipulation.Original.Center.Y;

            transform.ScaleX = _scaleX * e.PinchManipulation.CumulativeScale;
            transform.ScaleY = _scaleY * e.PinchManipulation.CumulativeScale;
        }
    }

    private void image_OnManipulationStarted(object sender, ManipulationStartedEventArgs e)
    {
        // the user has started manipulating the screen, set starting points
        var transform = (CompositeTransform)image.RenderTransform;
        _scaleX = transform.ScaleX;
        _scaleY = transform.ScaleY;
        _translationX = transform.TranslateX;
        _translationY = transform.TranslateY;
    }

但与其他 windows 手机 UI 的流畅度相比,它感觉非常平静和僵硬.运动中没有惯性.

But the compared to the smoothness of the rest of the windows phone UI it feels very placid and stiff. There is no inertia in the movement.

有没有办法让动作更流畅?使用动画和故事板是一种解决方法吗?我已经尝试使用 ScrollView 至少获得平滑的平移,但是 ManipulationDelta 事件没有正确触发.

Is there a way to make the movements more smooth? Is using animations and storyboards a way to go about it? I've tried using ScrollView for at least getting smooth panning but then the ManipulationDelta events are not firing correctly.

推荐答案

我知道你在谈论 8,我会发布一个与 7 相关的文章的链接,但它在玩 Windows Phone 时非常有用所以这里是:

I know you're talking about 8 and I'll post a link to an article related to 7, but it was very useful when playing around with Windows Phone so here it goes:

https://www.wintellect.com/building-touch-interfaces-for-windows-phones-part-3/

我不认为从那以后发生了很大的变化......

I don't imagine that much has changed since then...

这篇关于在 Windows Phone 8 上平滑缩放和平移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆