Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

horizontally collapsible panel in WPF

Tags:

c#

wpf

I'm trying to create a side collapsible panel that include StackPanel

enter image description here

For that Tried use Expander like following

<Expander Width="auto" ExpandDirection="Left" HorizontalAlignment="Right">
    <Expander.Header>
        <Border BorderBrush="Black" BorderThickness="1">                       
            <StackPanel>
                <Grid>                  
                </Grid>
            </StackPanel>    
        </Border>
    </Expander.Header>
</Expander>

But this is not working properly, can't do the function that I expected.

like image 886
Kelum Avatar asked Oct 12 '25 12:10

Kelum


1 Answers

As Maciek Świszczowski said, you need to properly align your expander and put the contents inside the context section of the expander. Also, assuming you want it to fill the entire left section, I would recommend you use a Grid to hold it all, like so:

Example:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Expander ExpandDirection="Right" HorizontalAlignment="Left">
        <Border BorderBrush="Black" BorderThickness="1">
        </Border>
    </Expander>
</Grid>

Here's what it looks like (I put a blue background and some text in the expander, and just a red stack panel in the second column in order to make it really clear).

Expanded:
Expanded

Collapsed:
Collapsed

like image 51
Eliza Bennet Avatar answered Oct 15 '25 03:10

Eliza Bennet