ContentSource Property

ContentPresenter.ContentSource Property


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

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

public string ContentSource { get; set; }

Property Value

Type: System.String

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

This property should only be used when the ContentPresenter is in a template. When a template contains a ContentPresenter with ContentSource set to "Abc", the Content, ContentTemplate, and ContentTemplateSelector properties of the ContentPresenter are automatically aliased to Abc, AbcTemplate, and AbcTemplateSelector, respectively. Beginning with the .NET Framework 3.5 Service Pack 1, setting ContentSource to "Abc" also causes the ContentStringFormat property to be aliased to AbcStringFormat.

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

Identifier field


Metadata properties set to true


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"/>

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft