In a WPF form, I have an expander that expands above other controls, such as buttons :
<Expander Grid.Row="0" Panel.ZIndex="99" Name="searchMenuExpander" Header="Search menu" FontWeight="Bold" HorizontalAlignment="Stretch" Margin="10,10,0,0" MinWidth="510" MinHeight="200" VerticalAlignment="Top" Foreground="MidnightBlue" Cursor="Arrow">
<Grid Background="White">
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<TextBlock Text="Name" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,10,0,0" Width="65" Height="20" Cursor="Arrow" />
<TextBox Name="nameSearchTextBox" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="115,10,0,0" Width="100" Height="20"/>
</Grid>
</Expander>
<Button Content="Button" Height="34" Width="85"/>
My problem is that my controls that are behind the expander are not clickable anymore, even when the expander is not expanded. What is happening? How could I get rid of this bug?
I found a way of doing it, with code behind. I put my
Expander
in aCanvas
and I added to myExpander
two events:Expanded="searchMenuExpander_Expanded"
andCollapsed="searchMenuExpander_Collapsed"
which are defined as: