WP7 GestureListener 上图像宽度/高度的限制 [英] Constraints on Image Width/Height on WP7 GestureListener

查看:15
本文介绍了WP7 GestureListener 上图像宽度/高度的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 GestureListener 添加到我正在尝试缩放的图像中,堆栈溢出答案如下:如何在WP7中放大和缩小图像?

I added the GestureListener to an image i'm trying to have zoom like this Stack Overflow answer here: How to zoom in and zoom out Images in WP7?

问题是图像永远不会停止缩放,并覆盖页面上的其他控件.这涵盖了页面上的几个重要按钮.

The problem is that the image does not ever stop zooming, and covers other controls on the page. This covers a few important buttons on the page.

此外,它允许图像变得非常小以至于很难放大,并且允许图像离屏幕太远以至于很难将其恢复.

In addition, it allows the image to get so small that it's very hard to make it bigger, and allows the image to go so far off the screen where it's too hard to bring it back.

我的目标是:将图像保留在分配给它的网格行中,以免覆盖其他控件.防止图像的宽度/高度变小防止宽度/高度过大防止图片被拖出屏幕.

My goal is to: Keep the image in the Grid Row it's assigned to, to not cover other controls. Prevent the width/height of the image from getting to small Prevent the Width/height of getting too big Prevent the image from being dragged off the screen.

有没有办法解决这个问题?Image 对象的宽度/高度没有被 GestureListener 修改,所以我不能简单地做

Is there a way to solve this? The Width/Height of the Image object are not modified by the GestureListener, so I cannot simply do

Image i = sender as Image;
if (i.Height == TOO_BIG)
return;
...

推荐答案

我最终解决了这个问题,并使其与以下博客中的代码完美配合:

I ended up fixing this and getting it work perfectly with the code from the following blog:

http://www.frenk.com/2011/03/windows-phone-7-correct-pinch-zoom-in-silverlight/

这是一组非常令人印象深刻的捏合/缩放功能.我的图像覆盖其他控件的问题是通过向网格添加剪辑来解决的,这里有详细说明:

It's a very impressive set of functions for Pinch/Zoom. The issue I had about the image covering other controls was fixed by adding clipping to the Grid, which is detailed here:

http://www.codeproject.com/Articles/36495/Silverlight-ClipToBounds-Can-I-Clip-It-Yes-You-Can.aspx

这篇关于WP7 GestureListener 上图像宽度/高度的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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