# Adding a Control to the Content Panel

## Content

[C1HeaderedContentControl](/componentone/api/wpf/online-basiclibrary/dotnet-framework-api/C1.WPF.4.6.2/C1.WPF.C1HeaderedContentControl.html) will accept one child control in its content panel. In this topic, you will learn how to add a WPF button control in XAML, and in code.
**In XAML**
To add a button control to the C1HeaderedContentControl's content panel in XAML, complete the following steps:

1. Place the following markup between the **c1:C1HeaderedContentContro**l and **</c1:C1HeaderedContentControl>** tags:

    ```xml
    <Button Content="Click" Height="Auto" Width="Auto"/>
    ```
2. Run the program and then expand **C1HeaderedContentControl**.

**In Code**

To add a button control to the **C1HeaderedContentControl**'s content panel in code, complete the following:

1. Add x:Name="C1HeaderedContentControl1" to the **c1:C1HeaderedContentControl** tag so that the control will have a unique identifier for you to call in code.
2. Enter Code view and add the following code beneath the **InitializeComponent()** method:
<br>
    DOC-DETAILS-TAG-OPEN
<br>
    DOC-SUMMARY-TAG-OPEN
<br>
    Visual Basic
<br>
    DOC-SUMMARY-TAG-CLOSE

    ```vbnet
    'Create the Button control
    Dim ContentButton As New Button()
    ContentButton.Content = "Click"
    'Set the Button Control's Width and Height properties
    ContentButton.Width = Double.NaN
    ContentButton.Height = Double.NaN
    'Add the Button to the content panel
    C1HeaderedContentControl1.Content = (ContentButton)
    ```

    DOC-DETAILS-TAG-CLOSE
<br>
    DOC-DETAILS-TAG-OPEN
<br>
    DOC-SUMMARY-TAG-OPEN
<br>
    C#
<br>
    DOC-SUMMARY-TAG-CLOSE

    ```csharp
    //Create the Button control
    Button ContentButton = new Button();
    ContentButton.Content = "Click";
    //Set the Button Control's Width and Height properties
    ContentButton.Width = double.NaN;
    ContentButton.Height = double.NaN;
    //Add the Button to the content panel
    C1HeaderedContentControl1.Content= (ContentButton);
    ```

    DOC-DETAILS-TAG-CLOSE
3. Run the program and then expand C1HeaderedContentControl.

**This Topic Illustrates the Following**:
When **C1HeaderedContentControl** is expanded, the button control appears in its content panel and resembles the following image:
![C1WPF Basic Library - HeaderedContentControl button in Content Panel](https://cdn.mescius.io/document-site-files/images/7e9deccd-1f1c-4ec7-af90-b4332b45dead/images/headercontentcontrol/controladdedtocontent.png)
Note that there isn't a header; this is because the Header property isn't set by default. To learn how to add text or controls to the header bar, see [Adding Content to the Header Bar](/componentone/docs/wpf/online-basiclibrary/overview/HeaderedContentControl/HeaderedContentControlTask-BasedHelp/AddingContenttotheHeaderBar).