简体   繁体   English

双击可在WP8中缩放图像?

[英]Double tap to zoom an image in WP8?

I have an Image within a ScrollViewer and I want the image to zoom on double tap. 我在ScrollViewer中有一个图像,我希望图像可以双击放大。 It zooms correctly, but the problem is with the scrollviewer. 它可以正确缩放,但问题出在滚动查看器上。 I want the ScrollViewer to scroll to a the point where the user tapped. 我希望ScrollViewer滚动到用户点击的位置。 Like if the user tapped on the bottom right corner, that part would get zoomed in and the scrollviewer would scroll to bring that point to the center of the screen. 就像用户点击右下角一样,该部分将被放大并且滚动查看器将滚动以将该点带到屏幕的中心。 Here's 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);
}

Anyone can help me with this? 有人可以帮我这个吗?

看看这个: MSDN帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM