Partilhar via


Border.BorderThickness Property

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

Gets or sets the thickness of the border.

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

Syntax

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

XAML Values

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

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

  • top&bottom
    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 BorderThickness.

Property Value

Type: System.Windows.Thickness
The thickness of the border in pixels. The default is 0 on all four sides.

Remarks

Dependency property identifier field: BorderThicknessProperty

The BorderThickness must be set to a nonzero value in order for a border to be visible. If the thickness is a positive value, the border is drawn inside the object's bounding box. If the thickness is negative, the border is drawn outside the object's bounding box.

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

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

Negative values for Thickness values are technically permitted, but should be used with caution when setting the BorderThickness property. Negative values cause drawing outside the normal areas assigned for layout, but they could be used in this way for deliberate effect.

Examples

The following example shows how to set a varying thickness for the border.

<Border BorderThickness="3,10,10,3" BorderBrush="Blue" Grid.Column="0" Grid.Row="2">
    <TextBlock Text="Thickness" />
</Border>

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.