WPF Layout Controls | ComponentOne
WPF Layout Controls / Expander / Content Area
In This Topic
    Content Area
    In This Topic

    The content panel of the Expander control is initially an empty area. However, you can add grids, text, images, and arbitrary controls in this content area. To simply add text to the content area of the Expander control, use the Content property or add a TextBox element to the content area as shown in the image below.

    Content Area Expander Control

    <c1:C1Expander x:Name="ExpanderControl" Header="Expand Me!" Content="Content Area"
        FontFamily="Cambria" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center">
    </c1:C1Expander>
    
    ExpanderControl.Content = "Content Area";
    

    However, there may be times where you want to add other elements, such as check boxes, grids or panels, to the content area. In this case, you can add the elements of your choice to the Expander control. For example, in the following example, we are adding a check box to the content area of the Expander control as shown in the image below.

    Checkbox content area Expander control

    The following code can be used to add a check box to the content area of the Expander control:

    <c1:C1Expander x:Name="ExpanderControl" FontFamily="Cambria" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" Width="280">
        <CheckBox Margin="10" VerticalAlignment="Center" x:Name="Condition" Content="CheckBox Inside Expander"/>
    </c1:C1Expander>
    
    CheckBox chkcontent = new CheckBox();
    //CheckBox as Expander Content
    chkcontent.Content = "CheckBox Inside Expander";
    ExpanderControl.Content = chkcontent;