[英]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.
现在我想制作
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. 似乎问题是Grid本身正在填充整个Window(没关系)但是在这个网格中,行旁边的区域旁边有空的空间。
What should I do? 我该怎么办?
For example I have rows witch height= 100 and 200 and whole grid have height 500 but should have 300. 例如,我有行高度= 100和200,整个网格高度为500但应该有300。
<Window
...
SizeToContent="WidthAndHeight">
<Grid>
...
</Grid>
</Window>
SizeToContent is the property that you want to set. SizeToContent是您要设置的属性。 I use this all of the time, it is great.
我一直用这个,很棒。
Set Window.SizeToContent property to WidthAndHeight. 将Window.SizeToContent属性设置为WidthAndHeight。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.