I have an Image within a ScrollViewer and I want the image to zoom on double tap. It zooms correctly, but the problem is with the scrollviewer. I want the ScrollViewer to scroll to a the point where the user tapped. 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帖子
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.