Поделиться через


Control.Padding Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the padding inside a control.

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

Syntax

'Declaration
Public Property Padding As Thickness
public Thickness Padding { get; set; }
<control Padding="uniform"/>
- or -
<control Padding="left&right,top&bottom"/>
- or -
<control Padding="left,top,right,bottom"/>

XAML Values

  • 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.

Remarks

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.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

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

Platforms

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