首页 > 解决方案 > 在 WPF 中切换到全屏模式后如何保持大小?

问题描述

到目前为止我只有以下

<Grid>
    <DockPanel  Background="Red">
        <DataGrid DockPanel.Dock="Bottom" Height="357"/>
        <StackPanel  Background="Gray"  DockPanel.Dock="Top" />
    </DockPanel>
</Grid>

我希望在程序放大时保留此布局; 在此处输入图像描述

不像现在我做大了: 在此处输入图像描述

我怎么能做这个?

标签: wpfwpf-controls

解决方案


是不是,你想要的?默认情况下,该DockPanel.LastChildFill属性设置为true。因此,如果您放大窗口,则StackPanel在您的情况下被放大。

<Grid>
    <DockPanel  Background="Red">
        <StackPanel  Background="Gray" MinHeight="75" DockPanel.Dock="Top" />
        <DataGrid DockPanel.Dock="Bottom"/>
    </DockPanel>
</Grid>

推荐阅读