【问题标题】:Fitting the content to the entire window space on maximization - WPF在最大化时使内容适合整个窗口空间 - WPF
【发布时间】:2015-04-22 09:13:14
【问题描述】:

当我运行项目并最大化窗口时,设计布局覆盖在窗口的左上部分。如何用最大化布局填充整个窗口?

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="40"/>
        <RowDefinition Height="50"/>
        <RowDefinition Height="320"/>
        <RowDefinition Height="70" />
        </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="50" />
    <ColumnDefinition Width="50" />
    <ColumnDefinition Width="50" />
    <ColumnDefinition Width="50" />
    <ColumnDefinition Width="50" />
    <ColumnDefinition Width="50" />
    <ColumnDefinition Width="50" />
    <ColumnDefinition Width="290" />

    </Grid.ColumnDefinitions>

    <Menu Background="#FFDED9D9" Grid.Row="0" Grid.ColumnSpan="8"  />

    <Menu Background="#FFDED9D9" Grid.Row="1" Grid.ColumnSpan="8" />

    <DataGrid Grid.Row="2" Grid.ColumnSpan="8"  />

    <StatusBar Grid.Row="3" Background="#FFDED9D9"  Grid.ColumnSpan="8" Margin="0,0,0,30" />
        </Grid>

【问题讨论】:

标签: wpf xaml expression-blend


【解决方案1】:

不设置LayoutGrid的所有Rows和Columns的Height和Width,而是将任意一个Column和Row的Height和Width设置为*

在这里,例如,您的 DataGrid 行的高度可以为 * &lt;RowDefinition Height="*"/&gt;。同样最后一个ColumnDefinition可以是&lt;ColumnDefinition Width="*" /&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-19
    • 2021-11-24
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多