#507 – Expander Control Lets you Expand/Collapse a Set of Controls
March 5, 2012 4 Comments
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.
<StackPanel> <Expander Header="Goals" Margin="10" > <StackPanel Orientation="Vertical"> <CheckBox Content="Read Ulysses"/> <CheckBox Content="Visit Bruges"/> <CheckBox Content="Take out the trash"/> </StackPanel> </Expander> <Label Content="Next guy in vertical StackPanel is down here"/> </StackPanel>
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.
Pingback: Dew Drop – March 5, 2012 (#1,279) | Alvin Ashcraft's Morning Dew
Pingback: #912 – Expanding an Expander Will Trigger Layout | 2,000 Things You Should Know About WPF
Which namespace and assembly is used for this expander?
System.Windows.Controls namespace, in PresentationFramework.dll. http://msdn.microsoft.com/en-us/library/system.windows.controls.expander(v=vs.110).aspx