The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ContentPresenter.Content Property

Gets or sets the data that is used to generate the child elements of a ContentPresenter.

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

public Object Content { get; set; }
<ContentPresenter Content="{Binding}"/>

Property Value

Type: System.Object
The data that is used to generate the child elements. The default is null.

Dependency property identifier field: ContentProperty

When you put a ContentPresenter in the ControlTemplate of a ContentControl, it automatically displays the Content of the templated control. For example, if you put a ContentPresenter in a ControlTemplate of a Button, the Content property of the ContentPresenter is implicitly bound to the Content of the Button that uses the ControlTemplate.

The XAML usage shown is the necessary when a ContentPresenter is part of a DataTemplate. When a ContentPresenter is part of a ControlTemplate, you do not need to template bind the Content property.

The following example creates a ControlTemplate for Button and uses a ContentPresenter to display the content of the Button.

Run this sample

    <Style x:Key="newButtonTemplate" TargetType="Button">
      <Setter Property="Template">
          <ControlTemplate TargetType="Button">
              <Rectangle Fill="{TemplateBinding Background}" />
                HorizontalAlignment="{TemplateBinding HorizontalAlignment}" 
                VerticalAlignment="{TemplateBinding VerticalAlignment}" />


  <TextBlock Text="ContentPresenter Demonstration" Margin="0,20,10,20"
           FontFamily="Verdana" FontSize="18" FontWeight="Bold"
           Foreground="#FF5C9AC9" Grid.Row="0" />

  <Button Content="default button" 
          Width="200" Margin="7"

  <Button Content="button with control template" 
          Style="{StaticResource newButtonTemplate}"
          Margin="7" Background="LightGray" Width="200"

  <Button Content="another button with control template" 
          Style="{StaticResource newButtonTemplate}"
          Margin="7" Background="LightBlue" Width="200" 



Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft