c# - WPF: How to find space available for Canvas? -
i'm using wpf shapes create hexagons (for game map) on canvas. after playing around scrollviewer, i've decided implement scrolling , zoom of map myself rather using wpf functionality, using wpf events mouse wheel, arrow keys etc. i'm placing (hex map) canvas last child inside dock panel available remaining space. dock panel set content of main window. want find out how big canvas can before put children on canvas can centre screen on hex want , add shapes (hexs) can seen. when zoomed out, long way remove polygons altogether , use method of rendering , when zoomed in long way add more details.
is there neat way of getting available space? way can think of work current dimensions of windows , subtract dimensions of outer elements of dock panel, feels rather messy.
you may use actualwidth
, actualheight
properties of canvas
determine size available it. sure horizontalalignment
, verticalalignment
set stretch
.
Comments
Post a Comment