简体   繁体   中英

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? Thanks in advance.

EDIT:

Code example:

 <Grid>
    <Button Content="CannotClick" Height="23" HorizontalAlignment="Left" Margin="314,91,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    <Expander 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM