3

我有一个 4 列的网格。第一列是一个 ZIndex 为 99 的 Canvas,里面是一个扩展器。展开方向设置为 RIGHT。当我单击标题时,扩展器会展开第 2 列的 OVER TOP ......这正是我想要的。我试图在第 4 列中复制这个(仅相反的方向),以便在展开时,它将显示在第 3 列上。即使我已将第二个扩展器的 ExpandDirection 标记为“左”,它仍然会扩展为右侧,并关闭屏幕。

这是工作扩展器:

<Canvas Grid.Column="0" Panel.ZIndex="99" Grid.RowSpan="4" VerticalAlignment="Stretch" Margin="0,5"> 
    <Expander ExpandDirection="Right" Style="{DynamicResource OptionsExpanderStyle}" VerticalAlignment="Stretch" Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Canvas}}}">
        <Border BorderBrush="Black" BorderThickness="0,0,2,0">
            <Grid Background="White">

            </Grid>
        </Border>
    </Expander>
</Canvas>

这是损坏的扩展器:

<Canvas x:Name="rightCanvas" Panel.ZIndex="99" Grid.RowSpan="4" Grid.Column="3" Margin="0,5">
    <Expander ExpandDirection="Left" Style="{DynamicResource OptionsExpanderStyle}" HorizontalAlignment="Right" VerticalAlignment="Stretch" Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Canvas}}}">
        <Border BorderBrush="Black" BorderThickness="2,0,0,0">
            <Grid Background="White" Width="150">

            </Grid>
        </Border>
    </Expander>
</Canvas>
4

1 回答 1

4

不要使用画布。

尝试这样的事情:

<Grid>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <TextBlock Background="LightBlue"
            TextAlignment="Center" Text="Left Column"/>
        <TextBlock Grid.Column="1" Background="LightCoral" 
            TextAlignment="Center" Text="Right Column"/>
    </Grid>
    <Expander Background="LightGray" ExpandDirection="Right"
        Header="LeftMenu" VerticalAlignment="Top" HorizontalAlignment="Left">
        <StackPanel Width="200">
            <TextBlock Text="Some menu stuff"/>
            <TextBlock Text="Some more"/>
        </StackPanel>   
    </Expander>
    <Expander Background="LightGray" ExpandDirection="Left"
        Header="RightMenu" VerticalAlignment="Top" HorizontalAlignment="Right">
        <StackPanel Width="200" >
            <TextBlock Text="Some menu stuff"/>
            <TextBlock Text="Some more"/>
        </StackPanel>
    </Expander>
</Grid>
于 2012-04-24T15:12:57.743 回答