The Header Content Control - Jesse Liberty - Silverlight Geek Page view counter

The Header Content Control

 

This quick introduction to the HeaderContentControl of the Silverlight Toolkit will lay the ground work for future entries on the Expander control.

To see the HeaderContentControl with as little fuss as possible, create a new Silverlight application and add a reference to the Microsoft.Windows.Controls.dll from the toolkit.

Page.xaml

 

Begin by adding a reference to the Microsoft.Windows.Controls.dll to your application and then declare an XML Name Space at the top of Page.xaml,

xmlns:control="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls" 

The HeaderControl consists of two parts: the header part and the contents part,

<Grid x:Name="LayoutRoot" Background="White">

<control:HeaderedContentControl 
x:Name="SimpleHeaderContent" Grid.Row="0"> <control:HeaderedContentControl.Header> <TextBlock x:Name="HeaderContentControlHeader" Text="Header for simple Header Content Control" FontSize="16" FontFamily="Georgia" FontWeight="Bold" /> </control:HeaderedContentControl.Header> <control:HeaderedContentControl.Content> <TextBlock x:Name="Message" Text="Content for the content control." TextWrapping="Wrap" FontFamily="Comic Sans MS" FontSize="24" Margin="10" /> </control:HeaderedContentControl.Content> </control:HeaderedContentControl> </Grid>

In the code shown above we are using text for both the header and the content portions,

HeaderInFF

Not Just Text

An interesting thing happens if you put a page with a  HeaderContentControl into Expression Blend, and then template the control…

ContentPresenters

The control consists of a pair of ContentPresenter objects within a stack panel.  If, however, the Header (e.g.,) is a ContentPresenter, then it is in no way restricted to text. 

(Close Blend and don't save the changes)

Let's add an image to Page.xaml's directory and then make that image a compiled resource by adding it to the project

AddExisting

Make sure the Build Action (in the properties window) is set to Resource,

BuildAction

 

Now we can return to Page.xaml and remove the text and substitute the Image,

<control:HeaderedContentControl.Header>
   <!--   <TextBlock x:Name="HeaderContentControlHeader"
             Text="Header for simple Header Content Control"
             FontSize="16"
             FontFamily="Georgia"
             FontWeight="Bold" /> -->
  
  <Image Source="LogoSmall.jpg"
         Stretch="UniformToFill"
         VerticalAlignment="Stretch"
         HorizontalAlignment="Stretch"
         MaxHeight="100"
         MaxWidth="100" /> 
</control:HeaderedContentControl.Header>
The result is immediately obvious,
ContentControlHeaderlWithImage 

 

The HeaderContentControl makes a powerful building block, especially when combined with, e.g., the Expander, as we'll see very soon.

 

 


MORE Header Controls Video


This work is licensed under a Creative Commons Attribution By license.
Published Saturday, January 17, 2009 10:17 PM by jesseliberty
Filed under: ,

Comments

# Dew Drop - January 18, 2009 | Alvin Ashcraft's Morning Dew

Pingback from  Dew Drop - January 18, 2009 | Alvin Ashcraft's Morning Dew

# Silverlight Travel &raquo; The Header Content Control

Pingback from  Silverlight Travel &raquo; The Header Content Control

Monday, January 19, 2009 12:40 AM by Silverlight Travel » The Header Content Control

# The Header Content Control - Jesse Liberty - Silverlight Geek

Thank you for submitting this cool story - Trackback from DotNetShoutout

Friday, January 23, 2009 12:40 PM by DotNetShoutout

# Toolkit: Header Controls Video Posted

MORE Blog entry on HeaderContentControl &#160; I'm happy to say that my latest video on the Silverlight

Monday, January 26, 2009 4:08 PM by Jesse Liberty - Silverlight Geek

# Toolkit: Header Controls Video Posted

MORE Blog entry on HeaderContentControl I'm happy to say that my latest video on the Silverlight Toolkit

Monday, January 26, 2009 4:53 PM by Microsoft Weblogs

# Programming with Silverlight, WPF &amp; .NET &raquo; Die Header Content Control

Pingback from  Programming with Silverlight, WPF &amp; .NET &raquo; Die Header Content Control

# Expander Control Part 1

I recently described the HeaderControl from the Silverlight Toolkit .&#160; Derived from the HeaderControl

Monday, February 02, 2009 11:33 AM by Jesse Liberty - Silverlight Geek

# Expander Control Part 1

I recently described the HeaderControl from the Silverlight Toolkit .&#160; Derived from the HeaderControl

Monday, February 02, 2009 11:49 AM by Microsoft Weblogs