gpt4 book ai didi

xaml - 如何将 stackpanel 分成 7 个等高的矩形

转载 作者:行者123 更新时间:2023-12-02 04:23:50 27 4
gpt4 key购买 nike

我正在开发 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>

有人可以帮我吗?

最佳答案

以下内容应该可以为您完成:

<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" />

关于xaml - 如何将 stackpanel 分成 7 个等高的矩形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28473100/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com