c# - How to Restrict canvas size in wpf when Zoomed -


i designing wpf in visual studio 2010 application implementing zoom feature in canvas. event is:

  < canvas mousewheel="canvas_mousewheel" /> 

and backend in xaml.cs is:

  const double scalerate = 1.1;    private void canvas_mousewheel(object sender, mousewheeleventargs e)         {              if (e.delta > 0)             {                 st.scalex *= scalerate;                 st.scaley *= scalerate;             }             else             {                 st.scalex /= scalerate;                 st.scaley /= scalerate;             }         }  

the problem when zooming figure in canvas ,the whole canvas expanding , taking whole space undesired.because want zoom in canvas not expand , have defined max height , max width well.

kindly me this.

perhaps:

 private void canvas_mousewheel(object sender, mousewheeleventargs e)     {         double maxscale = 2.0;          if (e.delta > 0)         {             st.scalex *= scalerate;             st.scaley *= scalerate;         }         else         {             st.scalex /= scalerate;             st.scaley /= scalerate;         }          if(st.scalex > maxscale)         {             st.scalex = maxscale;         }          if(st.scaley > maxscale)         {             st.scaley = maxscale;         }      }  

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -