【发布时间】:2011-11-01 10:28:38
【问题描述】:
我有两个网格行,它们的内容会有所不同。
我希望顶行的内容在行内垂直居中。
并且底行与底部垂直对齐。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="60*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" VerticalAlignment="Top">
<Grid VerticalAlignment="Center">
<StackPanel>
...
</StackPanel>
</Grid>
</Grid>
<StackPanel Grid.Row="1" VerticalAlignment="Bottom" d:LayoutOverrides="GridBox">
...
</StackPanel>
</Grid>
这应该是它的样子。
+-----------------------------+ +--------------------------------+
| | | |
| | | |
| | | |
| Content Centered | | |
| | | |
| | | Content Centered |
| | | |
+-----------------------------+ or | |
| | | |
| | | |
| | | |
| | +--------------------------------+
| | | |
| Content at the bottom | | Content at the bottom |
+-----------------------------+ +--------------------------------+
行的内容可能会有所不同,我曾在某些时候使用过行定义,但它不起作用,因为我不知道任何一行的固定高度。
【问题讨论】:
-
嗯,你需要定义一些
RowDefinitions否则你不会走远。另外,如果您需要布局方面的帮助,请绘制一张该死的图像。 -
有关 RowDefinition 值,请参见 msdn.microsoft.com/en-us/library/…,但您可以将 Auto 和 * 作为值......它们不必固定
标签: silverlight windows-phone-7