0

这是我的代码(顺便说一句,它不起作用):

<DockPanel MinWidth="776" Margin="13" LastChildFill="True" Height="522" VerticalAlignment="Top">
    <Grid DockPanel.Dock="Top" MinWidth="200">
        <Grid.RowDefinitions>
            <RowDefinition Height="70" />
            <RowDefinition Height="*"/>
            <RowDefinition Height="150" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
</Grid>
...
</DockPanel>

当我垂直调整控件大小时,所有东西都粘在顶部(我想要的,除了中间要拉伸)。

提前致谢!

4

2 回答 2

0

您将不得不从停靠面板LastChildFill="True", Height="522" VerticalAlignment="Top"中删除一些值,以阻止网格调整大小。

尝试这个:

<DockPanel MinWidth="776" >
        <Grid DockPanel.Dock="Top" MinWidth="200">
            <Grid.RowDefinitions>
                <RowDefinition Height="70" />
                <RowDefinition Height="*"/>
                <RowDefinition Height="150" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Rectangle Fill="Blue" Grid.Row="0" />
            <Rectangle Fill="Green" Grid.Row="1" />
            <Rectangle Fill="Red" Grid.Row="2" />
        </Grid>
    </DockPanel>
于 2013-02-06T20:18:51.600 回答
0

如果您可以坚持使用停靠面板,则可以执行以下操作:

<DockPanel LastChildFill="true">
    <DockPanel DockPanel.Dock="Top" Height="70" />
    <DockPanel DockPanel.Dock="Bottom" Height="150" />
    <DockPanel DockPanel.Dock="Top"><!-- Expandable content here--></DockPanel>
</DockPanel>
于 2013-02-06T20:04:44.823 回答