ContentPresenter ContentPresenter ContentPresenter Class

Definition

Displays the content of a ContentControl. Can also provide content presentation for non-controls. Provides a base class for specialized presenters such as ScrollContentPresenter.

public class ContentPresenterpublic class ContentPresenterPublic Class ContentPresenter
<ContentPresenter .../>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited properties

Inherited events

Inherited methods

Remarks

Typically, you use the ContentPresenter directly within the ControlTemplate of a ContentControl to mark where the content to be presented appears.

A ContentPresenter is often used to apply characteristics to text content, which are set into a Content property using only a string for the text (or some indirect equivalent such as a Binding or a RESX resource). For this reason the properties of a ContentPresenter are similar to the properties of the TextElement class. (The TextElement class is a base class for several elements that aren't controls but are used to format the text that might appear in a control or layout container.)

Tip

Starting in Windows 10, ContentPresenter defines new border properties that let you draw a border around the ContentPresenter without using an additional Border element. The new properties are BorderBrush, BorderThickness, CornerRadius, and Padding.

<ContentPresenter BorderBrush="Red" BorderThickness="2" CornerRadius="10" Padding="12">
</ContentPresenter>

A ContentPresenter can use a logic class to influence which template to use for templated data content at run-time. For more info, see the ContentTemplateSelector property.

If the ContentPresenter is in the ControlTemplate of a ContentControl, the ContentPresenter behavior will implicitly bind to the ContentTemplate and Content properties of the templated ContentControl.

ContentPresenter derived classes

ContentPresenter is the parent class for these classes:

Examples

This example shows a typical placement of a ContentPresenter object element as part of the ControlTemplate for a ContentControl. This example is a simplification of the Windows Runtime XAML default style for HyperlinkButton. One example VisualState is included to show how the ContentPresenter properties are changed based on state. The ContentPresenter is within a Border in the composition; it's common for content controls to have the ContentPresenter nested within one other parent element, and that parent element often template-binds some of the control properties that a ContentPresenter doesn't have. Note also how the ContentPresenter uses {TemplateBinding} markup extension to bind HorizontalAlignment / VerticalAlignment values to the control properties of where the template is applied.

    <!-- Default style for Windows.UI.Xaml.Controls.Primitives.HyperlinkButton -->
    <Style TargetType="HyperlinkButton">
...
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
...
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="HyperlinkButton">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
...
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource HyperlinkDisabledThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Margin="3">
                            <ContentPresenter x:Name="ContentPresenter"
                                              Content="{TemplateBinding Content}"
                                              ContentTransitions="{TemplateBinding ContentTransitions}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                    />
                        </Border>
                        <!--focus visuals omitted-->
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Constructors

ContentPresenter() ContentPresenter() ContentPresenter() ContentPresenter()

Initializes a new instance of the ContentPresenter class.

public ContentPresenter()public New()Public Sub New()public ContentPresenter()
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Properties

Background Background Background Background

Gets or sets the Brush to apply to the background of content handled by the ContentPresenter.

public Brush Background { get; set; }public Brush Background { get; set; }Public ReadWrite Property Background As Brushpublic Brush Background { get; set; }
<ContentPresenter Background="{StaticResource resourceName}"/>

Value
Brush Brush Brush

The brush used as the background brush for the contents. The default is a null brush from a pure code perspective, but system style defaults set this to White (for Light theme) or Black (for Dark theme).

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

BackgroundProperty BackgroundProperty BackgroundProperty BackgroundProperty

Identifies the Background dependency property.

public static DependencyProperty BackgroundProperty { get; }public static DependencyProperty BackgroundProperty { get; }Public Static ReadOnly Property BackgroundProperty As DependencyPropertypublic static DependencyProperty BackgroundProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Background dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

BorderBrush BorderBrush BorderBrush BorderBrush

Gets or sets a brush that describes the border fill of the content presenter.

public Brush BorderBrush { get; set; }public Brush BorderBrush { get; set; }Public ReadWrite Property BorderBrush As Brushpublic Brush BorderBrush { get; set; }
<ContentPresenter BorderBrush="{StaticResource resourceName}"/>

Value
Brush Brush Brush

The brush that is used to fill the content presenter's border. The default is null, (a null brush) which is evaluated as Transparent for rendering.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The BorderThickness value must be greater than 0 in order to see the BorderBrush value take effect.

BorderBrushProperty BorderBrushProperty BorderBrushProperty BorderBrushProperty

Identifies the BorderBrush dependency property.

public static DependencyProperty BorderBrushProperty { get; }public static DependencyProperty BorderBrushProperty { get; }Public Static ReadOnly Property BorderBrushProperty As DependencyPropertypublic static DependencyProperty BorderBrushProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the BorderBrush dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

BorderThickness BorderThickness BorderThickness BorderThickness

Gets or sets the border thickness of the content presenter.

public Thickness BorderThickness { get; set; }public Thickness BorderThickness { get; set; }Public ReadWrite Property BorderThickness As Thicknesspublic Thickness BorderThickness { get; set; }
<ContentPresenter BorderThickness="uniform"/>
- or -
<ContentPresenter BorderThickness="left&right,top&bottom"/>
- or -
<ContentPresenter BorderThickness="left,top,right,bottom"/>
Value
Thickness Thickness Thickness

The border thickness of the content presenter, as a Thickness value.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

BorderThicknessProperty BorderThicknessProperty BorderThicknessProperty BorderThicknessProperty

Identifies the BorderThickness dependency property.

public static DependencyProperty BorderThicknessProperty { get; }public static DependencyProperty BorderThicknessProperty { get; }Public Static ReadOnly Property BorderThicknessProperty As DependencyPropertypublic static DependencyProperty BorderThicknessProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the BorderThickness dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

CharacterSpacing CharacterSpacing CharacterSpacing CharacterSpacing

Gets or sets the uniform spacing between characters, in units of 1/1000 of an em.

public int CharacterSpacing { get; set; }public int CharacterSpacing { get; set; }Public ReadWrite Property CharacterSpacing As intpublic int CharacterSpacing { get; set; }
<ContentPresenter CharacterSpacing="int"/>
Value
int int int

The uniform spacing between characters, in units of 1/1000 of an em. The default is 0. Positive values increase tracking and loosen character spacing. Negative values decrease tracking and tighten the character spacing.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

CharacterSpacingProperty CharacterSpacingProperty CharacterSpacingProperty CharacterSpacingProperty

Identifies the CharacterSpacing dependency property.

public static DependencyProperty CharacterSpacingProperty { get; }public static DependencyProperty CharacterSpacingProperty { get; }Public Static ReadOnly Property CharacterSpacingProperty As DependencyPropertypublic static DependencyProperty CharacterSpacingProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the CharacterSpacing dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Content Content Content Content

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

public object Content { get; set; }public object Content { get; set; }Public ReadWrite Property Content As objectpublic object Content { get; set; }
<ContentPresenter Content="{Binding}"/>
Value
object object object

The data that is used to generate the child elements. The default is null.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ContentProperty ContentProperty ContentProperty ContentProperty

Identifies the Content dependency property

public static DependencyProperty ContentProperty { get; }public static DependencyProperty ContentProperty { get; }Public Static ReadOnly Property ContentProperty As DependencyPropertypublic static DependencyProperty ContentProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Content dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ContentTemplate ContentTemplate ContentTemplate ContentTemplate

Gets or sets the template that is used to display the content of the control.

public DataTemplate ContentTemplate { get; set; }public DataTemplate ContentTemplate { get; set; }Public ReadWrite Property ContentTemplate As DataTemplatepublic DataTemplate ContentTemplate { get; set; }
<ContentPresenter ContentTemplate="{Binding}"/>
Value
DataTemplate DataTemplate DataTemplate

A DataTemplate that defines the visualization of the content. The default is null.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ContentTemplateProperty ContentTemplateProperty ContentTemplateProperty ContentTemplateProperty

Identifies the ContentTemplate dependency property.

public static DependencyProperty ContentTemplateProperty { get; }public static DependencyProperty ContentTemplateProperty { get; }Public Static ReadOnly Property ContentTemplateProperty As DependencyPropertypublic static DependencyProperty ContentTemplateProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the ContentTemplate dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ContentTemplateSelector ContentTemplateSelector ContentTemplateSelector ContentTemplateSelector

Gets or sets a selection object that changes the DataTemplate to apply for content presented in the ContentPresenter, based on processing information about the content item or its container at run time.

public DataTemplateSelector ContentTemplateSelector { get; set; }public DataTemplateSelector ContentTemplateSelector { get; set; }Public ReadWrite Property ContentTemplateSelector As DataTemplateSelectorpublic DataTemplateSelector ContentTemplateSelector { get; set; }
<ContentPresenter ContentTemplateSelector="selectorReference" />

Value
DataTemplateSelector DataTemplateSelector DataTemplateSelector

A selection object that changes the DataTemplate to apply for content.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ContentTemplateSelectorProperty ContentTemplateSelectorProperty ContentTemplateSelectorProperty ContentTemplateSelectorProperty

Identifies the ContentTemplateSelector dependency property.

public static DependencyProperty ContentTemplateSelectorProperty { get; }public static DependencyProperty ContentTemplateSelectorProperty { get; }Public Static ReadOnly Property ContentTemplateSelectorProperty As DependencyPropertypublic static DependencyProperty ContentTemplateSelectorProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the ContentTemplateSelector dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ContentTransitions ContentTransitions ContentTransitions ContentTransitions

Gets or sets the collection of Transition style elements that apply to content presented by the ContentPresenter.

public TransitionCollection ContentTransitions { get; set; }public TransitionCollection ContentTransitions { get; set; }Public ReadWrite Property ContentTransitions As TransitionCollectionpublic TransitionCollection ContentTransitions { get; set; }
<contentPresenter>
  <contentPresenter.ContentTransitions>
    <TransitionCollection>
      oneOrMoreTransitions
    </TransitionCollection>
  </contentPresenter.ContentTransitions>
</contentPresenter>
Value
TransitionCollection TransitionCollection TransitionCollection

The strongly typed collection of Transition style elements.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Important

The XAML syntax for all properties that use a TransitionCollection value is unusual in that you must declare an explicit TransitionCollection object element as the value, and then provide object elements as child elements of TransitionCollection for each of the transition animations you want to use. For most other XAML collection properties you could omit the collection object element because it can be implicit, but properties that use TransitionCollection don't support the implicit collection usage. For more info on implicit collections and XAML, see XAML syntax guide.

Transition animations play a particular role in UI design of your app. The basic idea is that when there is a change or transition, the animation draws the attention of the user to the change.

ContentTransitionsProperty ContentTransitionsProperty ContentTransitionsProperty ContentTransitionsProperty

Identifies the ContentTransitions dependency property.

public static DependencyProperty ContentTransitionsProperty { get; }public static DependencyProperty ContentTransitionsProperty { get; }Public Static ReadOnly Property ContentTransitionsProperty As DependencyPropertypublic static DependencyProperty ContentTransitionsProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the ContentTransitions dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

CornerRadius CornerRadius CornerRadius CornerRadius

Gets or sets the radius for the corners of the content presenter's border.

public CornerRadius CornerRadius { get; set; }public CornerRadius CornerRadius { get; set; }Public ReadWrite Property CornerRadius As CornerRadiuspublic CornerRadius CornerRadius { get; set; }
<ContentPresenter CornerRadius="uniformRadius"/>
- or -
<ContentPresenter CornerRadius="topLeft,topRight,bottomRight,bottomLeft"/>

Value
CornerRadius CornerRadius CornerRadius

The degree to which the corners are rounded, expressed as values of the CornerRadius structure.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Member components of a CornerRadius value cannot be negative.

CornerRadiusProperty CornerRadiusProperty CornerRadiusProperty CornerRadiusProperty

Identifies the CornerRadius dependency property.

public static DependencyProperty CornerRadiusProperty { get; }public static DependencyProperty CornerRadiusProperty { get; }Public Static ReadOnly Property CornerRadiusProperty As DependencyPropertypublic static DependencyProperty CornerRadiusProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the CornerRadius dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontFamily FontFamily FontFamily FontFamily

Gets or sets the preferred top-level font family for the text content presented by the ContentPresenter.

public FontFamily FontFamily { get; set; }public FontFamily FontFamily { get; set; }Public ReadWrite Property FontFamily As FontFamilypublic FontFamily FontFamily { get; set; }
<ContentPresenter FontFamily="fontFamily" />
-or-
<ContentPresenter FontFamily="fontFamilyName[,fallbackFontFamilyName]" />
-or-
<ContentPresenter FontFamily="fontURI#fontFamily" />
Value
FontFamily FontFamily FontFamily

A FontFamily object that specifies the preferred font family, or a primary preferred font family with one or more fallback font families. For information about defaults, see the FontFamily class topic.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontFamilyProperty FontFamilyProperty FontFamilyProperty FontFamilyProperty

Identifies the FontFamily dependency property.

public static DependencyProperty FontFamilyProperty { get; }public static DependencyProperty FontFamilyProperty { get; }Public Static ReadOnly Property FontFamilyProperty As DependencyPropertypublic static DependencyProperty FontFamilyProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontFamily dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontSize FontSize FontSize FontSize

Gets or sets the font size for the text content presented by the ContentPresenter.

public double FontSize { get; set; }public double FontSize { get; set; }Public ReadWrite Property FontSize As doublepublic double FontSize { get; set; }
<ContentPresenter FontSize="double" .../>
Value
double double double

A non-negative value that specifies the font size, measured in pixels.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontSizeProperty FontSizeProperty FontSizeProperty FontSizeProperty

Identifies the FontSize dependency property.

public static DependencyProperty FontSizeProperty { get; }public static DependencyProperty FontSizeProperty { get; }Public Static ReadOnly Property FontSizeProperty As DependencyPropertypublic static DependencyProperty FontSizeProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontSize dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontStretch FontStretch FontStretch FontStretch

Gets or sets the font stretch for the text content presented by the ContentPresenter.

public FontStretch FontStretch { get; set; }public FontStretch FontStretch { get; set; }Public ReadWrite Property FontStretch As FontStretchpublic FontStretch FontStretch { get; set; }
<ContentPresenter FontStretch="fontStretchMemberName"/>
Value
FontStretch FontStretch FontStretch

The requested font stretch, as a FontStretch constant. The default is Normal.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontStretchProperty FontStretchProperty FontStretchProperty FontStretchProperty

Identifies the FontStretch dependency property.

public static DependencyProperty FontStretchProperty { get; }public static DependencyProperty FontStretchProperty { get; }Public Static ReadOnly Property FontStretchProperty As DependencyPropertypublic static DependencyProperty FontStretchProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontStretch dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontStyle FontStyle FontStyle FontStyle

Gets or sets the font style for the presented content.

public FontStyle FontStyle { get; set; }public FontStyle FontStyle { get; set; }Public ReadWrite Property FontStyle As FontStylepublic FontStyle FontStyle { get; set; }
<ContentPresenter FontStyle="fontStyleMemberName"/>
Value
FontStyle FontStyle FontStyle

The requested font style, which is a FontStyle constant name. The default is Normal.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontStyleProperty FontStyleProperty FontStyleProperty FontStyleProperty

Identifies the FontStyle dependency property.

public static DependencyProperty FontStyleProperty { get; }public static DependencyProperty FontStyleProperty { get; }Public Static ReadOnly Property FontStyleProperty As DependencyPropertypublic static DependencyProperty FontStyleProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontStyle dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontWeight FontWeight FontWeight FontWeight

Gets or sets the top-level font weight for the text content presented by the ContentPresenter.

public FontWeight FontWeight { get; set; }public FontWeight FontWeight { get; set; }Public ReadWrite Property FontWeight As FontWeightpublic FontWeight FontWeight { get; set; }
<ContentPresenter FontWeight="fontWeightsValue"/>
Value
FontWeight FontWeight FontWeight

The requested font weight, which is a FontWeight that is obtained from one of the FontWeights property values. The default is Normal.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

FontWeightProperty FontWeightProperty FontWeightProperty FontWeightProperty

Identifies the FontWeight dependency property.

public static DependencyProperty FontWeightProperty { get; }public static DependencyProperty FontWeightProperty { get; }Public Static ReadOnly Property FontWeightProperty As DependencyPropertypublic static DependencyProperty FontWeightProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontWeight dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Foreground Foreground Foreground Foreground

Gets or sets the Brush to apply to the text content handled by the ContentPresenter.

public Brush Foreground { get; set; }public Brush Foreground { get; set; }Public ReadWrite Property Foreground As Brushpublic Brush Foreground { get; set; }
<ContentPresenter Foreground="{StaticResource resourceName}"/>

Value
Brush Brush Brush

The brush used as the foreground brush for the text contents. The default is a null brush from a pure code perspective, but system style defaults set this to Black (for Light theme) or White (for Dark theme).

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ForegroundProperty ForegroundProperty ForegroundProperty ForegroundProperty

Identifies the Foreground dependency property.

public static DependencyProperty ForegroundProperty { get; }public static DependencyProperty ForegroundProperty { get; }Public Static ReadOnly Property ForegroundProperty As DependencyPropertypublic static DependencyProperty ForegroundProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Foreground dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

HorizontalContentAlignment HorizontalContentAlignment HorizontalContentAlignment HorizontalContentAlignment

Gets or sets the horizontal alignment of the content.

public HorizontalAlignment HorizontalContentAlignment { get; set; }public HorizontalAlignment HorizontalContentAlignment { get; set; }Public ReadWrite Property HorizontalContentAlignment As HorizontalAlignmentpublic HorizontalAlignment HorizontalContentAlignment { get; set; }
<ContentPresenter  HorizontalContentAlignment="horizontalAlignmentMemberName"/>
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

HorizontalContentAlignmentProperty HorizontalContentAlignmentProperty HorizontalContentAlignmentProperty HorizontalContentAlignmentProperty

Identifies the HorizontalContentAlignment dependency property.

public static DependencyProperty HorizontalContentAlignmentProperty { get; }public static DependencyProperty HorizontalContentAlignmentProperty { get; }Public Static ReadOnly Property HorizontalContentAlignmentProperty As DependencyPropertypublic static DependencyProperty HorizontalContentAlignmentProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the HorizontalContentAlignment dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

IsTextScaleFactorEnabled IsTextScaleFactorEnabled IsTextScaleFactorEnabled IsTextScaleFactorEnabled

Gets or sets whether automatic text enlargement, to reflect the system text size setting, is enabled.

public bool IsTextScaleFactorEnabled { get; set; }public bool IsTextScaleFactorEnabled { get; set; }Public ReadWrite Property IsTextScaleFactorEnabled As boolpublic bool IsTextScaleFactorEnabled { get; set; }
<ContentPresenter IsTextScaleFactorEnabled="bool"/>
Value
bool bool bool

true if automatic text enlargement is enabled; otherwise, false.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty

Identifies the IsTextScaleFactorEnabled dependency property.

public static DependencyProperty IsTextScaleFactorEnabledProperty { get; }public static DependencyProperty IsTextScaleFactorEnabledProperty { get; }Public Static ReadOnly Property IsTextScaleFactorEnabledProperty As DependencyPropertypublic static DependencyProperty IsTextScaleFactorEnabledProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the IsTextScaleFactorEnabled dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

LineHeight LineHeight LineHeight LineHeight

Gets or sets the height of each line of text content presented by the ContentPresenter.

public double LineHeight { get; set; }public double LineHeight { get; set; }Public ReadWrite Property LineHeight As doublepublic double LineHeight { get; set; }
<ContentPresenter LineHeight="double"/>
Value
double double double

The height in pixels of each line of text content. A value of 0 indicates that the line height is determined automatically from the current font characteristics. The default is 0.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

LineHeightProperty LineHeightProperty LineHeightProperty LineHeightProperty

Identifies the LineHeight dependency property.

public static DependencyProperty LineHeightProperty { get; }public static DependencyProperty LineHeightProperty { get; }Public Static ReadOnly Property LineHeightProperty As DependencyPropertypublic static DependencyProperty LineHeightProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the LineHeight dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

LineStackingStrategy LineStackingStrategy LineStackingStrategy LineStackingStrategy

Gets or sets a value that indicates how a line box is determined for each line of text.

public LineStackingStrategy LineStackingStrategy { get; set; }public LineStackingStrategy LineStackingStrategy { get; set; }Public ReadWrite Property LineStackingStrategy As LineStackingStrategypublic LineStackingStrategy LineStackingStrategy { get; set; }
Value
LineStackingStrategy LineStackingStrategy LineStackingStrategy

A value that indicates how a line box is determined for each line of text. The default is MaxHeight.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

LineStackingStrategyProperty LineStackingStrategyProperty LineStackingStrategyProperty LineStackingStrategyProperty

Identifies the LineStackingStrategy dependency property.

public static DependencyProperty LineStackingStrategyProperty { get; }public static DependencyProperty LineStackingStrategyProperty { get; }Public Static ReadOnly Property LineStackingStrategyProperty As DependencyPropertypublic static DependencyProperty LineStackingStrategyProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the LineStackingStrategy dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

MaxLines MaxLines MaxLines MaxLines

Gets or sets the maximum lines of text shown.

public int MaxLines { get; set; }public int MaxLines { get; set; }Public ReadWrite Property MaxLines As intpublic int MaxLines { get; set; }
Value
int int int

The maximum lines of text shown. The default is 0, which is a special value that represents "Auto" behavior. The value cannot be negative.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

MaxLinesProperty MaxLinesProperty MaxLinesProperty MaxLinesProperty

Identifies the MaxLines dependency property.

public static DependencyProperty MaxLinesProperty { get; }public static DependencyProperty MaxLinesProperty { get; }Public Static ReadOnly Property MaxLinesProperty As DependencyPropertypublic static DependencyProperty MaxLinesProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the MaxLines dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

OpticalMarginAlignment OpticalMarginAlignment OpticalMarginAlignment OpticalMarginAlignment

Get or sets a value that indicates how the font is modified to align with fonts of different sizes.

public OpticalMarginAlignment OpticalMarginAlignment { get; set; }public OpticalMarginAlignment OpticalMarginAlignment { get; set; }Public ReadWrite Property OpticalMarginAlignment As OpticalMarginAlignmentpublic OpticalMarginAlignment OpticalMarginAlignment { get; set; }
<ContentPresenter OpticalMarginAlignment="None"/>
-or-
<ContentPresenter OpticalMarginAlignment="TrimSideBearings"/>
Value
OpticalMarginAlignment OpticalMarginAlignment OpticalMarginAlignment

A value of the enumeration that indicates how the font is modified to align at different sizes. The default is None.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

OpticalMarginAlignmentProperty OpticalMarginAlignmentProperty OpticalMarginAlignmentProperty OpticalMarginAlignmentProperty

Identifies the OpticalMarginAlignment dependency property.

public static DependencyProperty OpticalMarginAlignmentProperty { get; }public static DependencyProperty OpticalMarginAlignmentProperty { get; }Public Static ReadOnly Property OpticalMarginAlignmentProperty As DependencyPropertypublic static DependencyProperty OpticalMarginAlignmentProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the OpticalMarginAlignment dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Padding Padding Padding Padding

Gets or sets the distance between the border and its child object.

public Thickness Padding { get; set; }public Thickness Padding { get; set; }Public ReadWrite Property Padding As Thicknesspublic Thickness Padding { get; set; }
Value
Thickness Thickness Thickness

The dimensions of the space between the border and its child as a Thickness value. Thickness is a structure that stores dimension values using pixel measures.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

A related property is Margin (a property of FrameworkElement ). For more info about the relationship between margin and padding, see Alignment, margin, and padding or Define layouts with XAML.

PaddingProperty PaddingProperty PaddingProperty PaddingProperty

Identifies the Padding dependency property.

public static DependencyProperty PaddingProperty { get; }public static DependencyProperty PaddingProperty { get; }Public Static ReadOnly Property PaddingProperty As DependencyPropertypublic static DependencyProperty PaddingProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Padding dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

TextLineBounds TextLineBounds TextLineBounds TextLineBounds

Gets or sets a value that indicates how the line box height is determined for each line of text displayed in the ContentPresenter.

public TextLineBounds TextLineBounds { get; set; }public TextLineBounds TextLineBounds { get; set; }Public ReadWrite Property TextLineBounds As TextLineBoundspublic TextLineBounds TextLineBounds { get; set; }
<ContentPresenter TextLineBounds="textLineBoundsValue"/>
Value
TextLineBounds TextLineBounds TextLineBounds

A value that indicates how the line box height is determined for each line of text. The default is Full.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

TextLineBoundsProperty TextLineBoundsProperty TextLineBoundsProperty TextLineBoundsProperty

Identifies the TextLineBounds dependency property.

public static DependencyProperty TextLineBoundsProperty { get; }public static DependencyProperty TextLineBoundsProperty { get; }Public Static ReadOnly Property TextLineBoundsProperty As DependencyPropertypublic static DependencyProperty TextLineBoundsProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the TextLineBounds dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

TextWrapping TextWrapping TextWrapping TextWrapping

Gets or sets how the element wraps text.

public TextWrapping TextWrapping { get; set; }public TextWrapping TextWrapping { get; set; }Public ReadWrite Property TextWrapping As TextWrappingpublic TextWrapping TextWrapping { get; set; }
Value
TextWrapping TextWrapping TextWrapping

A value that indicates how the element wraps text. The default is NoWrap.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

TextWrappingProperty TextWrappingProperty TextWrappingProperty TextWrappingProperty

Identifies the TextWrapping dependency property.

public static DependencyProperty TextWrappingProperty { get; }public static DependencyProperty TextWrappingProperty { get; }Public Static ReadOnly Property TextWrappingProperty As DependencyPropertypublic static DependencyProperty TextWrappingProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the TextWrapping dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

VerticalContentAlignment VerticalContentAlignment VerticalContentAlignment VerticalContentAlignment

Gets or sets the vertical alignment of the content.

public VerticalAlignment VerticalContentAlignment { get; set; }public VerticalAlignment VerticalContentAlignment { get; set; }Public ReadWrite Property VerticalContentAlignment As VerticalAlignmentpublic VerticalAlignment VerticalContentAlignment { get; set; }
<ContentPresenter  VerticalContentAlignment="verticalAlignmentValue"/>
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

VerticalContentAlignmentProperty VerticalContentAlignmentProperty VerticalContentAlignmentProperty VerticalContentAlignmentProperty

Identifies the VerticalContentAlignment dependency property.

public static DependencyProperty VerticalContentAlignmentProperty { get; }public static DependencyProperty VerticalContentAlignmentProperty { get; }Public Static ReadOnly Property VerticalContentAlignmentProperty As DependencyPropertypublic static DependencyProperty VerticalContentAlignmentProperty { get; }
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the VerticalContentAlignment dependency property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Methods

OnContentTemplateChanged(DataTemplate, DataTemplate) OnContentTemplateChanged(DataTemplate, DataTemplate) OnContentTemplateChanged(DataTemplate, DataTemplate) OnContentTemplateChanged(DataTemplate, DataTemplate)

Invoked when the value of the ContentTemplate property changes.

protected virtual void OnContentTemplateChanged(DataTemplate oldContentTemplate, DataTemplate newContentTemplate)protected virtual void OnContentTemplateChanged(DataTemplate oldContentTemplate, DataTemplate newContentTemplate)Protected Overridable Function OnContentTemplateChanged(oldContentTemplate As DataTemplate, newContentTemplate As DataTemplate) As voidprotected virtual void OnContentTemplateChanged(DataTemplate oldContentTemplate, DataTemplate newContentTemplate)
Parameters
oldContentTemplate
DataTemplate DataTemplate DataTemplate

The old value of the ContentTemplate property.

newContentTemplate
DataTemplate DataTemplate DataTemplate

The new value of the ContentTemplate property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

OnContentTemplateSelectorChanged(DataTemplateSelector, DataTemplateSelector) OnContentTemplateSelectorChanged(DataTemplateSelector, DataTemplateSelector) OnContentTemplateSelectorChanged(DataTemplateSelector, DataTemplateSelector) OnContentTemplateSelectorChanged(DataTemplateSelector, DataTemplateSelector)

Invoked when the value of the ContentTemplateSelector property changes.

protected virtual void OnContentTemplateSelectorChanged(DataTemplateSelector oldContentTemplateSelector, DataTemplateSelector newContentTemplateSelector)protected virtual void OnContentTemplateSelectorChanged(DataTemplateSelector oldContentTemplateSelector, DataTemplateSelector newContentTemplateSelector)Protected Overridable Function OnContentTemplateSelectorChanged(oldContentTemplateSelector As DataTemplateSelector, newContentTemplateSelector As DataTemplateSelector) As voidprotected virtual void OnContentTemplateSelectorChanged(DataTemplateSelector oldContentTemplateSelector, DataTemplateSelector newContentTemplateSelector)
Parameters
oldContentTemplateSelector
DataTemplateSelector DataTemplateSelector DataTemplateSelector

The old value of the ContentTemplateSelector property.

newContentTemplateSelector
DataTemplateSelector DataTemplateSelector DataTemplateSelector

The new value of the ContentTemplateSelector property.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Classes that derive from ContentPresenter can override this method in order to perform any custom logic that should apply, in cases where the selector logic that automatically chooses the DataTemplate based on context changes.