c# - WPF override a text on canvas + zooming dont work well -


problem 1

how can override written text without delete whole canvas content? can on c#? without adding elements in xaml code?

problem 2

i intergrated zoom function zooms if i'm pointing on drawn in canvas. how can zoom when i'm pointing on canvas?

xaml

<canvas x:name="coordinatesystembackground" verticalalignment="top" cursor="cross" mousewheel="coordinatesystembackground_mousewheel" rendertransformorigin="0.688,0.559" width="1200" height="720">     <scrollviewer grid.column="0" grid.row="0" verticalscrollbarvisibility="auto" horizontalscrollbarvisibility="auto" width="1200" height="750">         <canvas x:name="coordinatesystem" horizontalalignment="left" verticalalignment="top" cursor="cross" uselayoutrounding="false" canvas.left="0" width="1200" height="720">             <canvas.rendertransform>                 <scaletransform x:name="st"/>             </canvas.rendertransform>         </canvas>     </scrollviewer> </canvas> 

my zoom function

private void coordinatesystembackground_mousewheel(object sender, mousewheeleventargs e) {     // skalierungsfaktor        double scalerate = 1.1;      //transformiert gesamte canvas...       if (e.delta > 0)     {         st.scalex *= scalerate;         st.scaley *= scalerate;         labzoomfaktor.content = (int)((st.scalex * 100) - 100) + " %";     }     else     {         st.scalex /= scalerate;         st.scaley /= scalerate;         labzoomfaktor.content = (int)((st.scalex * 100) - 100) + " %";     }             } 

in order hit testing pick mouse input there needs non-null part of targeted element under cursor. in case canvas's children picking events , bubbling them canvas canvas empty space , won't pick mouse input. setting background="transparent" on canvas make entire thing visible hit testing.


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 -