I’m trying to add few contents to expander however, it throws following error
<Expander Name="myExpander" Background="Tan"
HorizontalAlignment="Left" Header="my expander"
ExpandDirection="Down" IsEnabled="True" Width="100" IsExpanded="True">
<Rectangle Width="10" Height="10" Fill="Red"/>
<Rectangle Width="10" Height="10" Fill="blue"/>
</Expander>
The object ‘Expander’ already has a child and cannot add ‘Rectangle’. ‘Expander’ can accept only one child.
I thought I can use Expander as a container holding few elements but it seems it only can hold on to one! any work around?
Thank you.
Amit
This is the case with many elements. You would nest a panel, such as a Grid or StackPanel, in order to layout multiple children.
Example:
This gives you unlimited flexibility on how to layout the children.