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 (isZoomed)
{
Img1.Width = Img1.Width / 1.5;
Img1.Height = Img1.Height / 1.5;
ImgHolder1.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
isPowerZoomed = false;
}
else
{
Img1.Width = Img1.Width * 1.5;
Img1.Height = Img1.Height * 1.5;
ImgHolder1.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
isPowerZoomed = true;
}
Point p = e.GetPosition(sender as UIElement);
ImgHolder1.ScrollToHorizontalOffset(p.X);
ImgHolder1.ScrollToVerticalOffset(p.Y);
}
Can anybody help me?
source
share