Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 263
LordSithamec Avatar asked Dec 27 '22 23:12

LordSithamec


1 Answers

<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.

like image 74
A.R. Avatar answered Dec 30 '22 13:12

A.R.