C1HeaderedContentControl 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:
Place the following markup between the <c1:C1HeaderedContentControl> and </c1:C1HeaderedContentControl> tags:
<Button Content="Click" Height="Auto" Width="Auto"/>
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:
Visual Basic
'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)
C#
//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);
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:
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.