WPF and Silverlight Edition Basic Library > HeaderedContentControl > C1HeaderedContentControl Elements > C1HeadreredContentControl Content Panel |
The C1HeaderedContentControl's content panel initially consists of an empty space. In the content panel, you can add grids, text, images, and arbitrary controls. When working in Visual Studio, elements in the content panel of the control can be added and moved on the control through a simple drag-and-drop operation.
You can add text to the content panel by setting the C1HeaderedContentControl's Content property or by adding a TextBox element to the content panel. Adding elements to the content panel at run time is simple: You can use either simple drag-and-drop operations or XAML to add elements. If you'd prefer to add a control at run time, you can use C# or Visual Basic code.
Content controls like C1HeaderedContentControl can only accept one child element at a time. However, you can circumvent this issue by adding a panel-based control as the C1HeaderedContentControl's child element. Panel-based controls, such as a StackPanel control, are able to hold multiple elements. The panel-based control meets the one control limitation of C1HeaderedContentControl, but its ability to hold multiple elements will allow you to show several controls in the content panel.
For task-based help about adding content to the content panel, see Adding Content to the content panel.
When you want to add something simple to the C1HeaderedContentControl content panel, such as an unformatted string or a single control, you can simply use the common XML attributes in your XAML markup, such as in the following:
<c1:C1HeaderedContentControl Content="Hello World"/>
However, there may be times where you want to add more complex elements, such as grids or panels, to the content panel. In this case you can use property element syntax, such as in the following:
XAML |
Copy Code
|
---|---|
<c1:C1HeaderedContentControl Width="150" Height="55" Name="C1HeaderedContentControl_Content"> <c1:C1HeaderedContentControl.Content> <StackPanel> <TextBlock Text="Hello"/> <TextBlock Text="World"/> </StackPanel> </c1:C1HeaderedContentControl.Content> </c1:C1HeaderedContentControl> |