xaml - WPF:stretch to parent loop -
in wpf application trying connect sizes app size. main grid stretches main window, canvas - main grid etc. not work. example, scrollviewer inside of canvas, stretches main grid. solution? simple code example:
<window height="400" width="200" ...> <grid horizontalalignment="stretch" verticalalignment="stretch"> <grid.rowdefinitions> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> </grid.columndefinitions> <canvas grid.row="0" grid.column="0" horizontalalignment="stretch" verticalalignment="stretch"> <scrollviewer horizontalalignment="stretch" verticalalignment="stretch"> </scrollviewer> </canvas> </grid> </window>
just remove canvas , work.
basically, canvas has infinite size default, in canvas cannot aligned, unless specify size maually.
<window height="400" width="200" ...> <grid> <scrollviewer> </scrollviewer> </grid> </window>
note, dont have specify grid's column , row definitions, if there's single cell. works default. also, horizontal , vertical alignment hav value "stretch" default, not have specified explicitelly well.
since there nothing scrollviewer inside grid, remove grid well:
<window height="400" width="200" ...> <scrollviewer> </scrollviewer> </window>
Comments
Post a Comment