What is ContentPresenter in WPF?

Content Presenter in WPF displays the content of a ContentControl.

You use the ContentPresenter in the ControlTemplate of a ContentControl to specify where the content is to be added. Every ContentControl type has a ContentPresenter in its default ControlTemplate.

 

When a ContentPresenter object is in a ControlTemplate of a ContentControl, the Content, ContentTemplate, and ContentTemplateSelector properties get their values from the properties of the same names of the ContentControl. You can have the ContentPresenter property get the values of these properties from other properties of the templated parent by setting the ContentSource property or binding to them

The following shows a Button Style that sets the ControlTemplate of a Button.

<Style TargetType="Button">

  <!--Set to true to not get any properties from the themes.-->

  <Setter Property="OverridesDefaultStyle" Value="True"/>

  <Setter Property="Template">

    <Setter.Value>

      <ControlTemplate TargetType="Button">

        <Grid>

          <Ellipse Fill="{TemplateBinding Background}"/>

          <ContentPresenter HorizontalAlignment="Center"

                            VerticalAlignment="Center"/>

        </Grid>

      </ControlTemplate>

    </Setter.Value>

  </Setter>

</Style>

 

 

Reference:

ContentPresenter