ContentControl Class
Collapse the table of content
Expand the table of content

ContentControl Class

Updated: February 2009

Represents a control with a single piece of content.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)]
public class ContentControl : Control, 

A ContentControl has a limited default style. If you want to enhance the appearance of the control, you can create a new DataTemplate. For more information, see Data Templating Overview. Another typical scenario is to use the ContentControl to show more information about an item selected in an ItemsControl control. For more information, see How to: Bind to a Collection and Display Information Based on Selection.

Content Model: ContentControl is the class from which other content controls inherit. For more information on the content model for ContentControl, see Controls Content Model Overview.

Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Themes.

The following example shows how to make a style for a ContentControl so that the control has an enhanced visual appearance.

<Style x:Key="ContentCtrl" TargetType="{x:Type ContentControl}">
  <Setter Property="Background" Value="Red"/>
  <Setter Property="Foreground" Value="Green"/>
  <Setter Property="FontSize" Value="20"/>
  <Setter Property="FontWeight" Value="Bold"/>
  <Setter Property="Template">
      <ControlTemplate TargetType="{x:Type ContentControl}">
          <!--Keep the Ellipse a circle when ContentControl.Width
              is set.-->
          <Ellipse Width="{TemplateBinding Width}"
                   Height="{TemplateBinding Width}"
                   Fill="{TemplateBinding Background}"/>
            <ContentPresenter VerticalAlignment="Center"


<ContentControl Width="75" Style="{StaticResource ContentCtrl}" 


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0




February 2009

Described how default styles change dependency properties.

Customer feedback.

July 2008

Added new members: ContentStringFormat property, OnContentStringFormatChanged method, ContentStringFormatProperty field.

SP1 feature change.

Community Additions

© 2015 Microsoft