c# - Image in Canvas in ScrollViewer -
so have image in scrollviewer (image pan- , zoomable):
<scrollviewer x:name="imagescrollviewer" sizechanged="image_sizechanged" scrollviewer.horizontalscrollbarvisibility="visible" scrollviewer.verticalscrollbarvisibility="visible"> <image x:name="image" stretch="uniform" renderoptions.bitmapscalingmode="fant" renderoptions.edgemode="aliased" mousemove="image_mousemove" mouseleftbuttondown="image_mouseleftbuttondown" sizechanged="image_sizechanged"> <image.layouttransform> <scaletransform x:name="scaletransform" scalex="1" scaley="1" centerx="0" centery="0" /> </image.layouttransform> </image> </scrollviewer> now, want draw onto image (just rectangles markings). guess direct drawing onto image (without system.drawing...) impossible?
i tried using canvas (so can add together rectangle objects) this:
<scrollviewer x:name="imagescrollviewer" sizechanged="image_sizechanged" scrollviewer.horizontalscrollbarvisibility="visible" scrollviewer.verticalscrollbarvisibility="visible"> <scrollviewer.inputbindings> <keybinding key="pagedown" command="local:mainwindow.nextpage" /> <keybinding key="pageup" command="local:mainwindow.previouspage" /> </scrollviewer.inputbindings> <canvas x:name="canvas"> <image x:name="image" stretch="uniform" renderoptions.bitmapscalingmode="fant" renderoptions.edgemode="aliased" mousemove="image_mousemove" mouseleftbuttondown="image_mouseleftbuttondown" sizechanged="image_sizechanged"> <image.layouttransform> <scaletransform x:name="scaletransform" scalex="1" scaley="1" centerx="0" centery="0" /> </image.layouttransform> </image> </canvas> </scrollviewer> now image isn't pan- nor zoomable anymore since canvas "destroys" whole layout , functionality. in code-behind depend on image (and it's actualwidth/actualheight, etc.) since capture mouse position , decide if it's hovered on marking of image.
any ideas this?
you can either a) bind canvas width/height image width/height coordinates same, b) utilize writablebitmap , drawing onto actual bitmap.
c# wpf xaml
No comments:
Post a Comment