Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I am using Zoom In and Zoom Out with an Image but how to reset the image with the original size.

Below is my code for Zoom In and Zoom Out...
private void ZoomInButton_Click(object sender, RoutedEventArgs e)
       {
           TransformGroup transformGroup = (TransformGroup)imgfromfoldercodebehind.RenderTransform;
           ScaleTransform transform = (ScaleTransform)transformGroup.Children[0];


           transform.ScaleX += 0.25;
           transform.ScaleY += 0.25;
       }

       private void ZoomOutButton_Click(object sender, RoutedEventArgs e)
       {

           TransformGroup transformGroup = (TransformGroup)imgfromfoldercodebehind.RenderTransform;
           ScaleTransform transform = (ScaleTransform)transformGroup.Children[0];
           if (transform.ScaleX > 0.25)
           {
               transform.ScaleX -= 0.25;
               transform.ScaleY -= 0.25;
           }
       }
       private void ResetButton_Click(object sender, RoutedEventArgs e)
       {
          //

       }


I need your help for the ResetButton_Click.....

Thanks
Posted
Comments
Mukesh Pr@sad 23-Jul-15 4:05am    
Use the code which you are using to display the image initially.
Md.Ashraf Ali 23-Jul-15 5:03am    
I'm binding the image from database and I don't want to call the method again to do so....I need to reset only like the zoom In and zoom out.
Mukesh Pr@sad 23-Jul-15 5:11am    
check the image property height and width in initial mode and supply the same in reset button.
Md.Ashraf Ali 23-Jul-15 5:23am    
This is my image properties..

<pre>
<Image x:Name="img" Stretch="Fill" MouseWheel="image_MouseWheel" Cursor="Hand"
HorizontalAlignment="Left" VerticalAlignment="Center"
RenderTransformOrigin="0.5, 0.5" >
</pre>

I tried to write in this way....

img.HorizontalAlignment = HorizontalAlignment.Left;
img.VerticalAlignment = VerticalAlignment.Center;
img.Stretch = Stretch.None;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900