ZoomOut and ZoomIn Images in Windows Phone 7 using double tap
I m doi开发者_如何学JAVAng ZoomOut of an image using the following code.
private void OnDoubleTap(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
{
scale.ScaleX += <some value>
scale.ScaleY += <some value>
}
I want to achieve the following thing. When I double tap for the first time on the image it should ZoomIn and when I double tap for the second time on the image it should come back to normal size. Any idea how to achieve it . Please let me know your suggestions.
Thanks, Mugu
Assuming your OnDoubleTap works, and normal scale is 1.
private void OnDoubleTap(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
{
if(scale.ScaleX == 1 && scale.ScaleY == 1) //The scale is currently 1, enlarge
{
scale.ScaleX = 1.5;
scale.ScaleY = 1.5;
} else { //Its bigger, reset to 1.
scale.ScaleX = 1;
scale.ScaleY = 1;
}
}
精彩评论