本文介绍了缩放 WP7 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找允许捏合缩放的 WP7 应用程序控件.我在像 DeepZoomContener 这样的 codeplex 上看到过,但效果不佳.有任何想法吗?我只需要通过捏合将其放大到 150%.
I'm lookin for a control for a WP7 app that allows zooming by pinch. I saw on codeplex smth like DeepZoomContener but is doesn't do well. Any ideas? I just need zoom to 150% by pinching that's all.
问候.
推荐答案
Thx Mick 但这与我的布局有点混乱.我做了一些更简单的事情.
Thx Mick but this messed up with my layout a bit. I did something more simple.
我使用 Silverlight Toolkit for WP7 并将捏合 GetureListener 添加到我的网格中
I use the Silverlight Toolkit for WP7 and add the pinch GetureListener to my grid
<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();
}
这篇关于缩放 WP7 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!