TextBlock.Padding Property

July 28, 2014

Gets or sets a value that indicates the thickness of padding space between the boundaries of the content area and the content displayed by a TextBlock.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public Thickness Padding { get; set; }
<TextBlock Padding="uniform"/>
- or -
<TextBlock Padding="left&Right,top&Bottom"/>
- or -
<TextBlock Padding="left,top,right,bottom"/>

XAML Values

uniform

A value that specifies a uniform Thickness. The uniform value is applied to all four Thickness properties (Left, Top, Right, Bottom).

left&Right

A value that specifies the Left and Right of a symmetrical Thickness.

top&Bottom

A value that specifies the Top and Bottom of a symmetrical Thickness.

left right top bottom

Values that specify the four possible dimension properties of a Thickness structure (Left, Top, Right, Bottom).

NoteNote:

In the XAML syntax, you can use a space instead of a comma as the delimiter between values.

Property Value

Type: System.Windows.Thickness
A Thickness structure that specifies the amount of padding to apply.

Dependency property identifier field: PaddingProperty

In XAML, Padding can be specified in the following ways:

  • As a single value that specifies uniform space in all directions (Padding="10").

  • As two values that specify horizontal and vertical dimensions (Padding="10,5").

  • As four values that represent left, top, right, and bottom padding independently (Padding="5,0,10,20").

For more information, see the Thickness class description.

If a specified padding thickness exceeds the corresponding content area dimension (for example, the sum of the left and right padding widths exceeds the content area width), the thickness of the padding is proportionally reduced to be no greater than the relevant content area dimension.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft