Border.Padding Property

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

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

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

XAML Values


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


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


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

left top right bottom

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

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

  • See Remarks for value type, value bounds, and edge-case considerations that affect both code and XAML usages of Padding.

Property Value

Type: System.Windows.Thickness
The dimensions of the space between the border and its child as a Thickness value. The Thickness values are in pixels.

Dependency property identifier field: PaddingProperty

The HorizontalAlignment and VerticalAlignment properties of the Border element are Stretch by default. This causes the border to stretch to the edges of the parent container and can look the same as setting a large Padding value. Setting HorizontalAlignment and VerticalAlignment to Center causes the Border to wrap its child element which shows the proper Padding value.

You can set a uniform padding for all sides of the border or set a specific value for each side. For details, see Thickness.

Negative values for Thickness values are technically permitted, but should be used with caution when setting the Padding property. Negative values cause the border to be drawn inside rather than outside the child object, but they could be used in this way for deliberate effect.

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

The following example shows how to set the Padding property for a Border.

<Grid ShowGridLines="True" x:Name="LayoutRoot" Background="White">
        <ColumnDefinition Width="*"/>
        <RowDefinition Height="*"/>
    <Border Grid.Row="0" Grid.Column="0" Padding="10" BorderThickness="50" HorizontalAlignment="Center" VerticalAlignment="Center"  BorderBrush="Blue">
        <Rectangle Height="100" Width="150" Fill="Red" /> 


Supported in: 5, 4, 3

Silverlight for Windows Phone

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

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

Community Additions