0

我有 2 张图片 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;
    }
4

1 回答 1

1

尝试这个,

    <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;
    }
于 2013-07-17T06:19:36.803 回答