XAML 如何在RelativePanel上均匀拉伸元素?

qrjkbowd  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(94)

我怎样才能平等地拉伸下面的矩形,使第一行的一半,第二行的一半,1/3 1/3 1/3分配?

<RelativePanel>
    <Rectangle Fill="Blue" Margin="5" x:Name="Pm25" MinHeight="100" MinWidth="100" RelativePanel.AlignLeftWithPanel="True"/>
    <Rectangle Fill="Blue" Margin="5" x:Name="Pm10" MinHeight="100" MinWidth="100" RelativePanel.AlignRightWithPanel="True"/>

    <Rectangle Fill="Blue" Margin="5" x:Name="O3" RelativePanel.Below="Pm25" MinHeight="100" MinWidth="100"/>
    <Rectangle Fill="Blue" Margin="5" x:Name="NO2" RelativePanel.RightOf="O3" RelativePanel.Below="Pm10" MinHeight="100" MinWidth="100"/>
    <Rectangle Fill="Blue" Margin="5" x:Name="SO2" RelativePanel.RightOf="NO2" RelativePanel.Below="Pm10" MinHeight="100" MinWidth="100"/>
    <Rectangle Fill="Blue" Margin="5" x:Name="CO" RelativePanel.Below="O3" MinHeight="100" MinWidth="100" RelativePanel.AlignLeftWith="Pm25" RelativePanel.AlignRightWithPanel="True"/>
</RelativePanel>

但目前它看起来像这样:

np8igboo

np8igboo1#

对于每一行矩形,创建一个水平方向的StackPanel,并将矩形放在那里。

相关问题