Click here to Skip to main content
15,615,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to create Three State Expander in C# WPF? Using Two expanders, Need to have Three state for both, minimize, restore and Maximize. When restoring both expanders should occupy equal height. When maximizing, one has to minimize and other has to maximize and occupy full area. How to achieve this?

What I have tried:

<pre><Grid DockPanel.Dock="Top" Name="myExpanderGrid">
                                    <Style TargetType="RowDefinition">
                                        <Setter Property="Height" Value="auto" />
                                            <DataTrigger Binding="{Binding IsBottomExpanded}" Value="True">
                                                <Setter Property="Height" Value="*" />
                                            <DataTrigger Binding="{Binding IsBottomExpanded}" Value="False">
                                                <Setter Property="Height" Value="5*" />

Just tried this, but I am unable to achieve the Maximize state of one of the expander at a time.
Gerry Schmitz 6-Oct-21 15:14pm    
If you have "3 states", then use a "3 value enum" instead of a bool to bind to your data trigger.
Gokulnath007 7-Oct-21 9:32am    
Thanks for your response. But when we click on the Expander, it is getting collapsed. Its like, by default both expanders will occupy equal space, when we click on one expander, it has to occupy the full space and the other will collapse and vice versa. When we collapse the maximized one, then both should expand equally as by default.
Gerry Schmitz 7-Oct-21 13:42pm    
If you want to "collapse" a row, you don't use "star" (*) settings; you use Auto or an absolute value. "Star" says to use some fraction or multiple of available space; so it never "collapses".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900