If you've seen a control with the Content property in
Silverlight (which there are many), then you see one of the most common types
of controls in the framework. Content controls can take a variety of values in
its content property. In its simplest form, the content of the control could
be text or some other primitive value (integer, etc.). But content controls
are not just limited to primitive data. Content controls can accept any type
of other Silverlight element within itself. This is done by using long-hand
syntax in the fom of:
Listing 1: Long-Form Syntax
<HeaderedContentControl.Content>
<TextBlock Text="My Content" />
</HeaderedContentControl.Content>
In this way, the content property can store another
Silverlight element, but it can only store a single element. This may seem
like a bad idea or even a bug, so how do you get around storing more than one
element? You could use a custom control or a user control, but at its simplest
form, it could be using a panel control, as in:
Listing 2: Using a panel for content
<HeaderedContentControl.Content>
<StackPanel>
<TextBlock Text="My" />
<TextBlock Text="Content" />
</StackPanel>
</HeaderedContentControl.Content>
While content controls have only one child, panel-based
controls or items-based controls, can store multiple children. So this type of
element meets this one control requirement, and the panel itself can store
multiple elements. It's a two-step process of sorts. This feature isn't
unique to the HeaderedContentControl object, but is a construct in Silverlight
(and is also available in WPF).