[英]Double tap to zoom an image in WP8?
我在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);
}
有人可以幫我這個嗎?
看看這個: MSDN帖子
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.