浮动面板(与对齐重叠)

时间:2012-06-16 14:19:59

标签: c# wpf

是否有可能在wpf的面板中浮动(与align重叠)子节点。 我有4个相互重叠的按钮。它们需要与左,右,顶部和底部对齐,并与父容器一起增长。请查看图片以获取更多信息。

enter image description here

1 个答案:

答案 0 :(得分:1)

这个怎么样?

<Grid>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="2*"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <Button Grid.Row="1" Grid.Column="0" Content="Left"/>
        <Button Grid.Row="1" Grid.Column="1" Content="Right"/>
    </Grid>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="2*"/>
            <ColumnDefinition Width="1*"/>
        </Grid.ColumnDefinitions>

        <Button Grid.Row="0" Grid.Column="1" Content="Top"/>
        <Button Grid.Row="1" Grid.Column="1" Content="Bottom"/>
    </Grid>
</Grid>

导致

enter image description here