wpf - How to Stretch window? -


i've problem window control in wpf project. don't find how stretch (resize) window or grid inner it. try attach properties horizontalcontentalignment = "stretch" , verticalcontentalignment = "stretch" consistent on both controls, nothing. have idea wrong ?

that part xaml:

window

title="mywindow" allowstransparency="true" background="transparent" windowstyle="none"  <grid x:name="maingrid" horizontalalignment="stretch" verticalalignment="stretch">             <border x:name="mainborder" background="{dynamicresource shellbackground}" cornerradius="15" borderthickness="3" margin="0,0,10,9">          <grid background="{dynamicresource brandingbrush}">             <grid.rowdefinitions>                 <rowdefinition height="30" />                 <rowdefinition height="auto" />                 <rowdefinition height="auto" />                 <rowdefinition />             </grid.rowdefinitions>                ...         </grid> </grid> 

/window

as @shoe has correctly hinted in comments, in order grid fill space of parent, @ least 1 of columns , rows must have dimension set "*". grid class page on msdn:

columns , rows defined within grid can take advantage of star sizing distribute remaining space proportionally. when star selected height or width of row or column, column or row receives weighted proportion of remaining available space. in contrast auto, distributes space evenly based on size of content within column or row.

in example (taken grid panel page on wpf tutorials.net), height fill complete height parent, uses "*" in 1 of rows... width of grid depend on content in first column, it's width set "auto":

<grid>     <grid.rowdefinitions>         <rowdefinition height="auto" />         <rowdefinition height="auto" />         <rowdefinition height="*" />         <rowdefinition height="28" />     </grid.rowdefinitions>     <grid.columndefinitions>         <columndefinition width="auto" />         <columndefinition width="200" />     </grid.columndefinitions> </grid> 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -