简体   繁体   English

WPF垂直网格探测器无法正常工作

[英]WPF vertical gridsplitter not working

I have a vertical gridsplitter, but I get an horizontal one instead. 我有一个垂直的网格分析器,但我得到一个水平的。 here is my XAML 这是我的XAML

<GroupBox Header="Phase Management">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="5"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="70*"/>
                <RowDefinition Height="30*"/>
            </Grid.RowDefinitions>

            <Button>Test column 0</Button>

            <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="#FFFFFF" ResizeBehavior="PreviousAndNext"/>

            <Button Grid.Column="2">Test column 2</Button>

        </Grid>
    </GroupBox>

在此输入图像描述

in the grid I have a stack panel, a data grid and some text boxes. 在网格中我有一个堆栈面板,一个数据网格和一些文本框。 Any idea of why I'm having the wrong behavior? 知道为什么我的行为有错吗?

Try to add additional properties like 尝试添加其他属性,如

<GridSplitter Grid.Column="1"
              ResizeDirection="Columns"
              ResizeBehavior="PreviousAndNext"
              HorizontalAlignment="Stretch"/>

for the direction (in your case "Columns") and for the behavior (in the example for resizing in both directions, left and right). 方向(在您的情况下为“列”)和行为(在左侧和右侧两个方向调整大小的示例中)。

Your XAML doesn't work. 您的XAML不起作用。 Please fix it. 请修理它。

Anyway I took some of your code and made some minor changes so it compiled and I get a vertical splitter: 无论如何,我采取了一些你的代码,并进行了一些小的改动,所以它编译,我得到一个垂直分割器:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="5"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="70*"/>
        <RowDefinition Height="30*"/>
    </Grid.RowDefinitions>

    <Button>Test column 0</Button>

    <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="#FFFFFF"/>

    <Button Grid.Column="2">Test column 2</Button>
</Grid>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM