我在ScrollViewer中有一个图像,我希望图像可以双击放大。它可以正确缩放,但问题出在滚动查看器上。我希望ScrollViewer滚动到用户点击的位置。就像用户点击右下角一样,该部分将被放大并且滚动查看器将滚动以将该点带到屏幕的中心。这是我正在使用的代码..
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);
}
任何人都可以帮我这个吗?