双击可缩放Windows Phone

时间:2014-08-27 10:41:52

标签: c# image windows-phone-8 image-zoom

双击缩放我有点问题,当我点击两次图像放大但我只能看到一半图像而我无法移动图像以查看另一半图像。我怎样才能看到所有图像?

代码是:

[XAML]

<!--LayoutRoot è la griglia radice in cui viene inserito tutto il contenuto della pagina-->
<Grid x:Name="LayoutRoot" Background="#FF0A5BC4">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--ContentPanel - inserire ulteriore contenuto qui-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <StackPanel Margin="-12,10,-11,98" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Image x:Name="immagine_Name"  Margin="1,1,1,1" Stretch="UniformToFill">
                <toolkit:GestureService.GestureListener>
                    <toolkit:GestureListener PinchStarted="GestureListener_PinchStarted"
                                                                     PinchDelta="GestureListener_PinchDelta"
                                                                     DoubleTap="GestureListener_DoubleTap"/>
                </toolkit:GestureService.GestureListener>
                <Image.RenderTransform>
                    <CompositeTransform x:Name="transform" ScaleX="1" ScaleY="1" TranslateX="0" TranslateY="0"/>
                </Image.RenderTransform>
            </Image>
        </StackPanel>
        <StackPanel Background="#FF094AB2" Margin="-12,675,-11,0">

        </StackPanel>
    </Grid>
</Grid>   

[C#]

private void GestureListener_DoubleTap(object sender, GestureEventArgs e)
{
    if (transform.ScaleX == 1 && transform.ScaleY == 1) //The scale is currently 1, enlarge
    {
        transform.ScaleX = 1.5;
        transform.ScaleY = 1.5;
    }
    else
    { //Its bigger, reset to 1.
        transform.ScaleX = 1;
        transform.ScaleY = 1;
    }
}

这是正常大小的图像: http://i.imgur.com/vlUlbes.jpg

这是双击后的图像,我无法移动以查看图像的其余部分: http://i.imgur.com/AZwsccq.jpg

感谢所有帮助我的人。

0 个答案:

没有答案