最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - How to have grid child (border) follow a column resize after being set to 0 pixels? - Stack Overflow

programmeradmin2浏览0评论

Background: in a Grid, I have two panels with GridSplitterfor resizing them, and a button to switch the collapse or uncollapse of the left panel.

The behavior is correct when uncollapsed.

When collapsed, if I use the GridSplitter, the left panel remains at 0 pixels, but I want it to follow the resize done by the GridSplitter.

How to achieve this? It seems that I could use of the the events of the GridSplitter, but which one, and how? Drag* Mouse*?

I have a user control:

<UserControl x:Class="SublimeTriptych.control.Repro"
             xmlns=";
             xmlns:x=";
             xmlns:mc="; 
             xmlns:d="; 
             xmlns:local="clr-namespace:SublimeTriptych.control"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid Name="ContainerGrid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="160"/>
            <ColumnDefinition Width="4"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Border Grid.ColumnSpan="1" Background="Gold"
                Visibility="{Binding PanelVisibility, Mode=OneWay, RelativeSource={RelativeSource AncestorType=local:Repro}}"/>
        <GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
        <Border Grid.Column="2" Background="Orange"/>

        <DockPanel Grid.ColumnSpan="3" Grid.Column="0" VerticalAlignment="Bottom">
            <Button HorizontalAlignment="Center" Command="{Binding SwitchVisibilityCommand, RelativeSource={RelativeSource AncestorType=local:Repro}}">
发布评论

评论列表(0)

  1. 暂无评论