如何在C#for Windows Phone应用程序中同时移动两个图像
本文关键字:移动 图像 两个 C#for Windows Phone 应用程序 | 更新日期: 2023-09-27 18:22:50
我有两个barTop和barBottom图像。如果我拖动barTop,我希望barBottom也被拖动。我的代码如下。我可以知道我该怎么做吗?
private void GestureListener_DragDelta(object sender, DragDeltaGestureEventArgs e)
{
barTopTT.X += e.HorizontalChange;
barTopTT.Y += e.VerticalChange;
barBottomTT.X += e.HorizontalChange;
barBottomTT.Y += e.VerticalChange;
}
试试这个,
<Image Height="100" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Name="img1" Margin="0,0,0,0" Stretch="Uniform" Source="/1.png">
<Image.RenderTransform>
<CompositeTransform x:Name="img1gesture"/>
</Image.RenderTransform>
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener DragDelta="GestureListener_DragDelta_1"/>
</toolkit:GestureService.GestureListener>
</Image>
<Image Height="100" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" Name="img2" Margin="0,0,0,0" Stretch="Uniform" Source="/1.png">
<Image.RenderTransform>
<CompositeTransform x:Name="img2gesture"/>
</Image.RenderTransform>
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener DragDelta="GestureListener_DragDelta_1"/>
</toolkit:GestureService.GestureListener>
</Image>
在C#中,
private void GestureListener_DragDelta_1(object sender, Microsoft.Phone.Controls.DragDeltaGestureEventArgs e)
{
img1gesture.TranslateX += e.HorizontalChange;
img2gesture.TranslateX += e.HorizontalChange;
img1gesture.TranslateY += e.VerticalChange;
img2gesture.TranslateY += e.VerticalChange;
}