AshbyEngineer
AshbyEngineer

Reputation: 153

Partially expand expander control in wpf

I have a stackpanel that contains an expander control and below that 3 rows of buttons. Depending on logic the buttons may be collapsed. If enough buttons are collapsed to eliminate a row of them, I would like the expander to open up revealing more of it contents. I need it to open up depending on how much room is available below it.

Is there anyway to partially open up an expander to make use of additional space if it becomes available?

Thanks Harold

Upvotes: 0

Views: 432

Answers (1)

TYY
TYY

Reputation: 2716

I think what you are trying to do is simpler than you make it sound,

You need the right container/ panel to achieve what you are asking. An example is like below :-

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Expander Grid.Row="0"/>
    <Button Grid.Row="1"/>
    <Button Grid.Row="2"/>
    <Button Grid.Row="3"/>
<Grid>  

With the Grid Panel if you use auto when the control within gets collapsed so does the space and because the first Expander's Grid row is * it will adjust to fill and free space.

Upvotes: 1

Related Questions