我正在使用Windows Phone 8应用程序,其中我有一个Stackpanel,我想在其中放入7个矩形。我希望这些矩形的高度相同,与屏幕尺寸无关。我尝试设置Height="*"
但是它给出了错误。
<StackPanel>
<Rectangle Fill="Violet" Height="*"></Rectangle>
<Rectangle Fill="Indigo" Height="*"></Rectangle>
<Rectangle Fill="Blue" Height="*"></Rectangle>
<Rectangle Fill="Green" Height="*"></Rectangle>
<Rectangle Fill="Yellow" Height="*"></Rectangle>
<Rectangle Fill="Orange" Height="*"></Rectangle>
<Rectangle Fill="Red" Height="*"></Rectangle>
</StackPanel>
任何人都可以帮我吗?
答案 0 :(得分:3)
以下内容应该为您完成:
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*">
<RowDefinition Height="*">
<RowDefinition Height="*">
<RowDefinition Height="*">
<RowDefinition Height="*">
<RowDefinition Height="*">
<RowDefinition Height="*">
<Grid.RowDefinitions>
<Rectangle Fill="Violet" Grid.Row="0" />
<Rectangle Fill="Indigo" Grid.Row="1" />
<Rectangle Fill="Blue" Grid.Row="2" />
<Rectangle Fill="Green" Grid.Row="3" />
<Rectangle Fill="Yellow" Grid.Row="4" />
<Rectangle Fill="Orange" Grid.Row="5" />
<Rectangle Fill="Red" Grid.Row="6" />
</Grid>
还有UniformGrid
可以为您执行此操作:
<UniformGrid Columns="1" Rows="7" />