Constraints on Image Width/Height on WP7 GestureListener

前端 未结 3 376
别那么骄傲
别那么骄傲 2021-01-16 13:27

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

相关标签:
3条回答
  • 2021-01-16 13:59

    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

    0 讨论(0)
  • 2021-01-16 14:03

    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;
        }
    
    0 讨论(0)
  • 2021-01-16 14:05

    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.

    0 讨论(0)
提交回复
热议问题