简体   繁体   中英

How to make Window Height adjust to content?

I have simple Window.
In this Window I have Grid with few Rows which height I am setting dynamicly.
Now I want to make Window.Height = sum of Grids Rows.
What a problem seems to be is that Grid itself is filling whole Window (it is ok) but in this grid there is empty space beside area occupied by rows.
What should I do?

For example I have rows witch height= 100 and 200 and whole grid have height 500 but should have 300.

<Window
...
SizeToContent="WidthAndHeight">
  <Grid>
  ...
  </Grid>
</Window>

SizeToContent is the property that you want to set. I use this all of the time, it is great.

Set Window.SizeToContent property to WidthAndHeight.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM