ContentPresenter.ContentSource Property

Gets or sets the base name to use during automatic aliasing.

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

public string ContentSource { get; set; }
/** @property */
public String get_ContentSource ()

/** @property */
public void set_ContentSource (String value)

public function get ContentSource () : String

public function set ContentSource (value : String)

<object ContentSource="string" .../>

Property Value

The base name to use during automatic aliasing. The default value is "Content".

Identifier field


Metadata properties set to true


This property should only be used when the ContentPresenter is in a template. It cannot be set directly. When a template contains a ContentPresenter with ContentSource="Abc", the Content, ContentTemplate, and ContentTemplateSelector properties of the ContentPresenter are automatically aliased to Abc, AbcContentTemplate, and AbcContentTemplateSelector, respectively.

The two most useful values for this property are "Content" and "Header".

The following example shows a style for a HeaderedContentControl that demonstrates the usage of the ContentSource property:

<Style TargetType="HeaderedContentControl">
  <Setter Property="Template">
      <ControlTemplate TargetType="{x:Type HeaderedContentControl}">
            <Rectangle Stroke="{TemplateBinding Background}"/>
            <ContentPresenter ContentSource="Header"/>
            <Rectangle Fill="{TemplateBinding Background}"/>
            <ContentPresenter ContentSource="Content"/>

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0