以增加的图像导航(翻译x,y)wp7

时间:2011-09-05 17:25:34

标签: c# silverlight image windows-phone-7

我想在增加的图像中导航,但我的代码不起作用。到目前为止我所拥有的:

 private void StartMoving(object sender, Microsoft.Phone.Controls.GestureEventArgs e) 
 {
     var finger1 = e.GetPosition(MainImage);
     var transform = (CompositeTransform)MainImage.RenderTransform;
     transform.Transform(finger1);
 }

XAML:

 <Image Name="MainImage">
     <toolkit:GestureService.GestureListener>
         <toolkit:GestureListener DoubleTap="OnDoubleTap" Flick="OnFlick"
                                  GestureBegin="StartMoving"
                                  PinchStarted="OnPinchStarted"
                                  PinchDelta="OnPinchDelta"/>
     </toolkit:GestureService.GestureListener>
     <Image.RenderTransform>
         <CompositeTransform ScaleX="1" ScaleY="1" TranslateX="0" TranslateY="0"/>
     </Image.RenderTransform>
 </Image>

我需要这样的事情:http://www.youtube.com/watch?v=FOk8m0MG6Lw

我该如何做到这一点?

1 个答案:

答案 0 :(得分:1)

   MainImage.ManipulationDelta += PhoneApplicationPage_ManipulationDelta;
        }...
        void PhoneApplicationPage_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) {
          // Scale the rectangle.
          // Move the rectangle.
          var transform = (CompositeTransform)MainImage.RenderTransform;
          if (transform.ScaleX != 1 || transform.ScaleY != 1) {
            transform.TranslateX += e.DeltaManipulation.Translation.X;
            transform.TranslateY += e.DeltaManipulation.Translation.Y;
          }
        }