奇怪Gridsplitter调整行为 [英] Weird Gridsplitter resizing behaviour

查看:224
本文介绍了奇怪Gridsplitter调整行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

得到了他的XAML:

<Window x:Class="correctionTests.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Menu Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" IsMainMenu="True">
            <MenuItem Header="_Ouvrir" Click="Open_Click"/>
        </Menu>
        <GroupBox Header="Tests : " VerticalAlignment="Top" Grid.Column="0" Grid.Row="1">
            <ListBox HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="testList"/>
        </GroupBox>
        <GridSplitter HorizontalAlignment="Right"
                      VerticalAlignment="Stretch"
                      Grid.Column="1"
                      Grid.Row="1"
                      Width="5"
                      Background="#FFBCBCBC"/>
        <UserControl x:Name="userContent" Grid.Column="2" Grid.Row="1"/>
    </Grid>
</Window>

现在的问题是,控制在列的大小时,我拉gridsplitter 0是递减到右侧,另一方面列0的控制的大小,同时拉动gridsplitter向左增加。

Now the problem is that the size of the controls on the column 0 is diminishing when i pull the gridsplitter to the RIGHT, on the other hand the size of the controls of the column 0 is increasing while pulling the gridsplitter to the left.

我已经发现了这个link 堆栈的建议第一列的宽度更改为自动。

I already found this link on stack that suggested to change the first column's width to Auto.

现在的问题是:如果我这样做,控件不调整了。

The problem is : if i do that, the controls does not resize anymore.

我怎样才能做到让自己的控制让所有的宽度可用? (与预期gridsplitter行为)?

How can i do so that my controls get all the width available ? (with the expected gridsplitter behaviour) ?

推荐答案

当你GridSplitter是单独的列,你必须
ResizeBehavior =PreviousAndNext

As your GridSplitter is on separate column, you have to set ResizeBehavior="PreviousAndNext"

这篇关于奇怪Gridsplitter调整行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆