How to zoom in and zoom out Images in WP7?

前端 未结 3 838
暖寄归人
暖寄归人 2020-12-02 21:07

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 app

3条回答
  •  情书的邮戳
    2020-12-02 21:48

    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:-

     
         
             
         
         
             
         
     
    

    Then in code-behind:-

        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;
        }
    

提交回复
热议问题