Free Study Guide for the Windows Presentation Framework exam 70-511: Headered Content Control

 

Headered controls are similar to other controls, but the headered control is a specific ContentControl class that exposes the Content property and also reveals the Header property.

Use the Header property to categorize the controls primary content, for instance a tab. The header on at tab control is the content on the tab. Headers support text, Image, StackPanel and Rectangle.

 

Example of a Grid that has a GroupBox, StackPanel, TabControl with two TabItem, ListBox.  The wrap panel is used to keep the ellipse and the TextBlock in the tab.  The GroupBox contains an expander which uses a LinearGadient and a TextBlock.

 

 <Page xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:sys="clr-namespace:System;assembly=mscorlib" 
      xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" >
  <TabControl VerticalAlignment="Bottom" 
              HorizontalAlignment="Left"  
              Width="500" 
              Height="350">
    <TabItem Header="Planet of Origin">
        What planet are you from?
    </TabItem>
    <TabItem>
      <TabItem.Header>
        <WrapPanel>
          <Ellipse Width="10" 
                   Height="10" 
                   Fill="PowderBlue" 
                   Margin="0,0,5,0"/>
          <TextBlock>
              Planetary System
          </TextBlock>
        </WrapPanel>
      </TabItem.Header>
      <TabItem.Content>
        <GroupBox Header="This is the groupbox" Margin="10">
            <Expander Margin="10" 
                    Width="340"
                    Header="My Expander" 
                    IsExpanded="True"
                    Foreground="White">
            <Expander.Background>
              <LinearGradientBrush>
                <LinearGradientBrush.GradientStops>
                    <GradientStop 
                      Offset="0" 
                      Color="Red"/>
                    <GradientStop 
                      Offset="1" 
                      Color="LemonChiffon"/>
              </LinearGradientBrush.GradientStops>
              </LinearGradientBrush>
            </Expander.Background>
            <TextBlock 
                TextWrapping="Wrap" 
                Foreground="White">
                Currently all space aliens are considered to be from 
                one of the planets in the Solar System.
            </TextBlock>
          </Expander>
        </GroupBox>
      </TabItem.Content>
    </TabItem>
  </TabControl>
</Page>

Reference: Developing Windows Applications with Microsoft Visual Studio 2010 and internet sites as indicated.