Double click to enlarge image in WP8?

I have an image inside ScrollViewer, and I want the image to be enlarged with a double click. It scales correctly, but the problem is with scrollviewer. I want ScrollViewer to scroll the point at which the user knocked. As if the user clicked on the lower right corner, this part would increase, and the scroll scroll would move this point to the center of the screen. Here is the code I'm using.

private void ImgHolder1_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
{
    //If zoomed in, then zoom out
    if (isZoomed)
    {
        Img1.Width = Img1.Width / 1.5;
        Img1.Height = Img1.Height / 1.5;
        ImgHolder1.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
        isPowerZoomed = false;
    }
    //else zoom in
    else
    {
        Img1.Width = Img1.Width * 1.5;
        Img1.Height = Img1.Height * 1.5;
        ImgHolder1.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
        isPowerZoomed = true;
    }

    //Scroll to offset
    Point p = e.GetPosition(sender as UIElement);
    ImgHolder1.ScrollToHorizontalOffset(p.X);
    ImgHolder1.ScrollToVerticalOffset(p.Y);
}

Can anybody help me?

+4
source share
1 answer

take a look at this: MSDN message

0
source

Source: https://habr.com/ru/post/1568028/


All Articles