1

我正在尝试创建一个扩展器,该扩展器具有一个切换按钮/标题作为左侧的细长条,但是当扩展时会填充窗口的其余部分,甚至是已经存在的材料。

我不确定最好的方法是什么。我可能想到了一个有 2 列的网格。首先是膨胀机,其次是其他材料。接下来我会有一个触发器,当 Expander IsExpanded 时将第二列宽度设置为零。

我不确定如何让它发挥作用,甚至不确定如何正确地做到这一点。

这是一些代码示例:

<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Name="SecondColumn" Width="*" />
        </Grid.ColumnDefinitions>


        <Expander ExpandDirection="Right" IsExpanded="True">

            <Expander.Resources>
                <Style TargetType="Expander">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Expander" >

                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsExpanded" Value="True" >
                                        <Setter TargetName="SecondColumn" Property="ColumnDefinition.Width" Value="0" />
                                    </Trigger>
                                </ControlTemplate.Triggers>

                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Expander.Resources>

            <ListBox >
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        </Expander>

        <TabControl Grid.Column="1" />

    </Grid>

我不想在展开时看到列表框,否则 TabControl

有任何想法吗?

4

1 回答 1

1

It sounds like you're wanting to do something similar to Karl Shifflett's example here. He's just modifying the z-index of the content control in this case and setting the row height manually to give the illusion of a popup, so you'd want to make sure you're not trying to ZIndex other visual elements similarly.

You will want to make sure you're setting ColumnSpan and RowSpan on your Expander so that when it does expand it covers the content of those rows.

于 2010-07-15T14:31:30.890 回答