如何在 WP7 中放大和缩小图像? [英] How to zoom in and zoom out Images in WP7?
本文介绍了如何在 WP7 中放大和缩小图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我制作了一个显示图像的应用程序.现在我想实现放大和缩小功能(通过使用两个指尖),就像在本机 Windows 手机照片查看器应用程序中一样.关于如何进行的任何想法.
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用于 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>
然后在代码隐藏中:-
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屋!
查看全文