Manuel
Manuel

Reputation: 2203

Howto zoom in/out in WinRT Image Control

I have a WinRT Metro application where i show an image. I now like to zoom in/out with a pinch gesture. Is there an easy way to activate this on the image control, or do i have to implement the whole gesture/pinch logic myself?

Upvotes: 0

Views: 2557

Answers (2)

Manuel
Manuel

Reputation: 2203

I found a better solution.

Just use a ScrollViewer control, this will to the whole zoom for you:

        <ScrollViewer x:Name="ImageScrollViewer"  HorizontalAlignment="Stretch" HorizontalScrollBarVisibility="Visible" VerticalAlignment="Stretch" MinZoomFactor="0.5" >
        <Grid>
            <Image x:Name="SmugImage"   Source="http://www.website.com/image.png"  Stretch="Uniform" Grid.Column="0" Grid.Row="0" />
        </Grid>
    </ScrollViewer>

Make sure to set HorizontalScrollBarVisibility to Visible, otherwise the image will be left aligned when you start zooming.

Upvotes: 6

Peter
Peter

Reputation: 521

According to a Windows Metro Forum here there isn't a built in handler for what u want to do, but they do link off to sample code for what i believe you are trying to achieve on this site

Upvotes: 2

Related Questions