The HeaderedContentControl is a new control added to the
Silverlight toolkit. The control provides a header and a footer that content
can be supplied to, whether static text or an individualized control makeup.
The control could appear like in Listing 6.
Listing 6: HeaderedControlControl
<HeaderedContentControl Header="My Header Text">
<Button Content="First" />
<Button Content="Second" />
<Button Content="Third" />
Here we have a headered control that has a static header
stating the "My Header Text" text. Silverlight (and likewise WPF)
support defining properties as children in this regard. While content is a
property of HeaderedContentControl and can be defined inline like the header,
adding complex content to a control (like child elements) requires defining the
content in this regard.
What appears is the My Header Text above the three buttons.
The buttons appear in a horizontal fashion, using this default setup.
Alternatively, using a StackPanel would have caused a vertical orientation
(unless the Orientation property was explicitly set to another value).
The HeaderedContentControl can supply any type of control
for the header or content regions. For instance, adding a textbox to the
header simply requires the header property in its template form and adding a
control to it in the form of:
Listing 7: Adding a Textbox to the Header
<TextBox Test="Text Entering Header" />
Now that we have a Textbox in the header, the user can enter
text and this text content can be submitted wherever it needs to go. This
control supplies a couple of options for supplying headers or content. First is
the Header and Content properties; it also supplies a HeaderTemplate and
ContentTemplate, useful for overriding the default templates of the control.
While the Header and Content properties supply the content, the template
overrides the entire template. Overriding the template may not have much of a
visible effect in this scenario, but it does in most controls that you'll use.
A custom template for a control uses a ControlTemplate object
to provide the interface that will override the default. If you override the
default template, you have to handle all of the interactions that control
performed. This isn't a daunting task for the HeaderedContentControl, but may
be for other controls like the Button control.