开发者

How to click content behind collapsed WPF expander?

When I collapse an expander, it visibly collapse, but I cannot click the content behind.

It occupies the same space as if it were expanded...

Is it possible to REALLY collapse an expander?

Code example:

 <Grid>
    <Button Content="CannotClick" Height="23" HorizontalAlignment="Left" Margin="314,91,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    <Expander 开发者_Go百科Header="expander1" Height="190" HorizontalAlignment="Left" Margin="306,32,0,0" Name="expander1" VerticalAlignment="Top" Width="95">
        <Grid>
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="7,106,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
        </Grid>
    </Expander>
</Grid>

The CannotClick Button is below the expanded area of the expander.


I was having the same problem and my solution was to not specify the Height of the Expander in the Expander property. This allow to modify content behind the expander(when collapsed) in the Editor and Executable

<Grid>
    <Button Content="CannotClick" Height="23" HorizontalAlignment="Left" Margin="314,91,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    <Expander Header="expander1" HorizontalAlignment="Left" Margin="306,32,0,0" Name="expander1" VerticalAlignment="Top" Width="95">
        <Grid>
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="7,106,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
        </Grid>
    </Expander>
</Grid>


This is not a problem with expander. The problem is that both your controls are placed on the same place.

To fix this, add rows to grid and insert each control into separate row, or replace grid with StackPanel

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜