This topic has not yet been rated - Rate this topic

Control.Padding Property

May 02, 2013

Gets or sets the padding inside a control.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
public Thickness Padding { get; set; }
<control Padding="uniform"/>
- or -
<control Padding="left&right,top&bottom"/>
- or -
<control Padding="left,top,right,bottom"/>

XAML Values

uniform

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

left&right

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

top+bottom

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

left right top bottom

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

  • In the XAML syntaxes shown above, you can also use a space rather than a comma as the delimiter between values.

  • See Remarks for additional notes about value constraints.

Property Value

Type: System.Windows.Thickness
The amount of space between the content of a Control and its Margin or Border. The default is a thickness of 0 on all four sides.

Dependency property identifier field: PaddingProperty

Negative values for Thickness values are technically permitted, but should be used with caution when setting the Padding property. Negative values will draw the content outside the bounds of the control surface, but could be used in this way for deliberate effect.

Non-integral values of a Thickness for Padding are technically permitted, but should generally be avoided. Non-integral values will introduce subpixel rendering, which can possibly result in antialiasing artifacts.

This property only affects a control whose template uses the Padding property as a parameter. On other controls, this property has no impact.

Windows Phone OS

Supported in: 8.0, 7.1, 7.0

Windows Phone

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.