如何放大和在WP7缩小图片? [英] How to zoom in and zoom out Images in WP7?

查看:133
本文介绍了如何放大和在WP7缩小图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做它显示。现在我想要实现放大和缩小功能(用两个指尖的),如本机Windows如何进行手机照片浏览器application.Any想法图像的应用程序。

I have made an application which displays Images .Now I want to implement zoom in and zoom out feature(by using two fingertip's) as in native windows phone photo viewer application.Any idea on how to proceed .

先谢谢了。

推荐答案

也许是最方便的方法是包括的的Silverlight for Windows Phone支持工具包。这包含了一个 GestureService ,这将有助于捏和旋转触摸手势。你可以把它应用到这样的图像: -

Perhaps the most expedient approach would be to include the Silverlight for Windows Phone Toolkit. This contains a GestureService that will help with pinch and rotate touch gestures. You could apply it to an image like this:-

 <Image Source="someSourceUrl" RenderTransformOrigin="0.5, 0.5" CacheMode="BitmapCache">
     <Image.RenderTransform>
         <CompositeTransform x:Name="transform" />
     </Image.RenderTransform>
     <toolkit:GestureService.GestureListener>
         <toolkit:GestureListener PinchStarted="OnPinchStarted" PinchDelta="OnPinchDelta" />
     </toolkit:GestureService.GestureListener>
 </Image>

然后在code-背后: -

Then in code-behind:-

    private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
    {
        initialAngle = transform.Rotation;
        initialScale = transform.ScaleX;
    }

    private void OnPinchDelta(object sender, PinchGestureEventArgs e)
    {
        transform.Rotation = initialAngle + e.TotalAngleDelta;
        transform.ScaleX = initialScale * e.DistanceRatio;
        transform.ScaleY = initialScale * e.DistanceRatio;
    }

这篇关于如何放大和在WP7缩小图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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