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 pr
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
I guess you can do it by restricting transform.ScaleX
and transform.ScaleY
in the below event handler.if initialScale
< somelength ,then only do the code.
private void OnPinchDelta(object sender, PinchGestureEventArgs e)
{
transform.Rotation = initialAngle + e.TotalAngleDelta;
transform.ScaleX = initialScale * e.DistanceRatio;
transform.ScaleY = initialScale * e.DistanceRatio;
}
This blog post shows how to implement Pinch/Zoom scaling on an image: http://alvaropeon.wordpress.com/2011/03/10/implementing-pinch-to-zoom-images-in-wp7/ The solution presented there is to limit at 4x the original size, but you could whatever you want. If you want to constrain it to it's parent, then just get the ActualWidth and ActualHeight of the parent as use those as your limits.