#507 – Expander Control Lets you Expand/Collapse a Set of Controls

You can use an Expander control to hide a set of controls.  When you click on the Expander, the hidden controls are shown.  When you click again, they are hidden again.

The Expander control is a ContentControl, so contains a single child element.  This is typically a panel control, so that you can then include multiple controls in the panel.

        <Expander Header="Goals" Margin="10" >
            <StackPanel Orientation="Vertical">
                <CheckBox Content="Read Ulysses"/>
                <CheckBox Content="Visit Bruges"/>
                <CheckBox Content="Take out the trash"/>
        <Label Content="Next guy in vertical StackPanel is down here"/>

Notice that when the Expander is expanded, it takes up more room in the container (a StackPanel in this example) and other child elements are shifted.


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

4 Responses to #507 – Expander Control Lets you Expand/Collapse a Set of Controls

  1. Pingback: Dew Drop – March 5, 2012 (#1,279) | Alvin Ashcraft's Morning Dew

  2. Pingback: #912 – Expanding an Expander Will Trigger Layout | 2,000 Things You Should Know About WPF

  3. degr8sid says:

    Which namespace and assembly is used for this expander?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: