Examining Various Silverlight Containers
page 5 of 8
by Brian Mains
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 36023/ 99

HeaderedContentControl

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">
      <HeaderedContentControl.Content>
            <Button Content="First" />
            <Button Content="Second" />
            <Button Content="Third" />
      </HeaderedContentControl.Content>
</HeaderedContentControl>

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

<HeaderedContentControl>
     <HeaderedContentControl.Header>
         <TextBox Test="Text Entering Header" />
     </HeaderedContentControl.Header>
 </HeaderedContentControl>

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.


View Entire Article

User Comments

Title: Microsoft.Windows.Controls   
Name: Evgen
Date: 2010-08-26 4:42:38 AM
Comment:
May be
Microsoft.Windows.Controls
instead of
System.Windows.Controls
?
Title: Silverlight   
Name: Prabhakar
Date: 2009-07-15 7:51:36 AM
Comment:
This is article very useful. I have query "Can we add a xmal file inside any panel/etc.." I want to display all my xaml files/controls to display in one page. Please advice me if it is possible.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-18 9:31:03 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search