【问题标题】:Fixed width on the column, when window is resized?调整窗口大小时,列上的固定宽度?
【发布时间】:2014-01-22 10:11:08
【问题描述】:

我有 2 个主要列,由 gridsplitter 分隔:

<Window x:Class="EnvironmentNet.ShellView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:caliburn="http://www.caliburnproject.org"
        Width="800"
        Height="400"
        Background="Black"
        ResizeMode="CanResizeWithGrip"
        >

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.2*" MinWidth="300" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="0.8*" MinWidth="400" />
        </Grid.ColumnDefinitions>

        <Grid Background="Red" x:Name="Nav" Grid.Column="0" />
        <GridSplitter HorizontalAlignment="Center" VerticalAlignment="Stretch" Width="5" Grid.Column="1" />
        <Grid Background="Green" x:Name="Content" Grid.Column="2"  />
    </Grid>

</Window>

这很好用,但是当我调整窗口大小时,左列也开始调整大小。调整窗口大小时,如何使左列保持固定宽度并使右列伸展?用户应该仍然可以使用 gridsplitter 手动调整左右列的大小。

谢谢

【问题讨论】:

    标签: wpf xaml


    【解决方案1】:

    为第一个 ColumnDefinition 设置 Width="Auto"。我试过这个。但这会导致一个问题 它使 GridSplitter 被拖到右角 如果根据您的要求这是不可接受的,那么它将无济于事。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-31
      • 1970-01-01
      • 2012-12-15
      • 1970-01-01
      • 2011-05-21
      • 1970-01-01
      • 2013-11-24
      相关资源
      最近更新 更多