locked
scaling an image RRS feed

  • Question

  • hello,

    I am developing an app where user should be able to scale an image using mouse.how should I proceed ??

    Tuesday, June 18, 2013 3:55 PM

Answers

  • You can use ScrollViewer for basic scaling and scrolling features.
    You can zoom with your mouse with CTRL + scroll wheel.

    Sample XAML:

    <ScrollViewer x:Name="scv" HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" MinZoomFactor="1" MaxZoomFactor="11">
        <Image x:Name="imgMain" Stretch="Uniform" />
    </ScrollViewer>

    But for more complex scenario you should use GestureRecognizer.
    You can find it in this sample on ObjectZoomPage scenario:

    http://code.msdn.microsoft.com/windowsapps/Input-Windows-8-gestures-62c6689b

    Tuesday, June 18, 2013 9:05 PM

All replies

  • What part of this do you need help with?

    You can detect the mouse by handling PointerEvents and then apply a scaling transform to the image based on where the pointer moves from the location it was pressed.

    --Rob

    Tuesday, June 18, 2013 4:04 PM
    Moderator
  • You can use ScrollViewer for basic scaling and scrolling features.
    You can zoom with your mouse with CTRL + scroll wheel.

    Sample XAML:

    <ScrollViewer x:Name="scv" HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" MinZoomFactor="1" MaxZoomFactor="11">
        <Image x:Name="imgMain" Stretch="Uniform" />
    </ScrollViewer>

    But for more complex scenario you should use GestureRecognizer.
    You can find it in this sample on ObjectZoomPage scenario:

    http://code.msdn.microsoft.com/windowsapps/Input-Windows-8-gestures-62c6689b

    Tuesday, June 18, 2013 9:05 PM