Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 带分离器的拉伸面板_Wpf_Wpf Controls - Fatal编程技术网

Wpf 带分离器的拉伸面板

Wpf 带分离器的拉伸面板,wpf,wpf-controls,Wpf,Wpf Controls,我想用三个面板和两个拆分器(水平和垂直拆分器)实现一个基本的WPF布局 左侧和底部的两个面板必须是可调用的,一个面板必须相应地拉伸 下面是一个简单的XAML: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="5"/>

我想用三个面板和两个拆分器(水平和垂直拆分器)实现一个基本的WPF布局

左侧和底部的两个面板必须是可调用的,一个面板必须相应地拉伸

下面是一个简单的XAML:

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

            <StackPanel Background="Aqua" Grid.Column="0" Name="leftPanel" >
                <TextBlock FontSize="35" Foreground="#58290A" TextWrapping="Wrap">Left Hand Side</TextBlock>
            </StackPanel>

            <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch"/>

            <Grid Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="5" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Label Content="... Clien Area .. Has to Stretch vertically and horizontally" Margin="10"></Label>
                    <Button Click="LeftButton_Click" Margin="10">Close Left Panel</Button>
                    <Button Click="BottomButton_Click" Margin="10">Close Bottom Panel</Button>
                </StackPanel>
                <GridSplitter Grid.Row="1" Background="Gray" HorizontalAlignment="Stretch"/>
                <ListBox Grid.Row="2" Background="Violet" Name="bottomPanel">
                    <ListBoxItem>Hello</ListBoxItem>
                    <ListBoxItem>World</ListBoxItem>
                </ListBox>
            </Grid>
        </Grid>
这段代码并没有像预期的那样工作:(.有WPF的专家吗?建议一种同时使用客户端区域(拉伸)和拆分器的解决方案吗

DockPanel将完美工作,但我需要拆分器


谢谢。

要折叠列,您需要将包含折叠面板的
列定义的
宽度更改为。

谢谢您快速正确的回答。它可以工作,但有一个错误。如果我触摸(调整拆分器大小)它立即停止工作。我认为原因是width属性正在从“自动”更改为某个大小,因此,是否有任何优雅的解决方案可以将宽度切换回“自动”?当我执行类似操作时,我也会隐藏GridSplitter及其列,当一侧折叠时,将其放置在周围没有意义。
    private void LeftButton_Click(object sender, RoutedEventArgs e)
    {
        leftPanel.Visibility = (leftPanel.Visibility == System.Windows.Visibility.Visible)? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
    }

    private void BottomButton_Click(object sender, RoutedEventArgs e)
    {
        bottomPanel.Visibility = (bottomPanel.Visibility == System.Windows.Visibility.Visible) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
    }