Border Border Border Border Class
Definition
Draws a border, background, or both, around another object.
public : sealed class Border : FrameworkElement, IBorderpublic sealed class Border : FrameworkElement, IBorderPublic NotInheritable Class Border Inherits FrameworkElement Implements IBorder// This API is not available in Javascript.
<Border>
singleChild
</Border>
- Inheritance
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Inherited Members
Inherited properties
Inherited events
Inherited methods
Examples
This example shows how to put a Border around several Rectangle objects contained in a StackPanel.
<Border BorderBrush="Gray" BorderThickness="4"
Height="108" Width="64">
<StackPanel>
<Rectangle Fill="Yellow"/>
<Rectangle Fill="Green"/>
</StackPanel>
</Border>
<Border Background="Coral" Width="300" Padding="10" CornerRadius="20">
<TextBlock FontSize="16">Text Surrounded by a Border</TextBlock>
</Border>
Remarks
Border is a container control that draws a border, background, or both, around another object. Here's a gray border around two rectangles.

You can specify basic properties of a Border by setting its Width, Height, BorderBrush, BorderThickness, and Background color. In addition, you can round the border corners by setting the CornerRadius property, and you can position the object inside the Border by setting the Padding property.
A Border can contain only one child object. If you want to put a border around multiple objects, wrap them in a container object such as StackPanel.
Constructors
Properties
Background Background Background Background
Gets or sets the Brush that fills the background (inner area) of the border.
public : Brush Background { get; set; }public Brush Background { get; set; }Public ReadWrite Property Background As Brush// This API is not available in Javascript.
<Border Background="{StaticResource resourceName}"/>
The brush that fills the background. The default is null, (a null brush) which is evaluated as Transparent for rendering.
Examples
The following example shows how to set the background of a Border to a solid color using an inline-defined attribute value "Cyan". The XAML parser uses this "Cyan" value to refer to the named color Colors.Cyan, and to create the SolidColorBrush instance that supplies the runtime value.
<Border Background="Cyan" CornerRadius="20" Grid.Column="2" Grid.Row="2">
<TextBlock Text="Background Brush" TextWrapping="Wrap" VerticalAlignment="Center" />
</Border>
Remarks
The Background value for a Border is visible underneath the inner area if the element that is the Child element has transparency or null value brushes for any of its defining area. It is also visible between the border edge and the Child content if nonzero values are applied for a Padding value.
- See Also
BackgroundProperty BackgroundProperty BackgroundProperty BackgroundProperty
Identifies the Background dependency property.
public : static DependencyProperty BackgroundProperty { get; }public static DependencyProperty BackgroundProperty { get; }Public Static ReadOnly Property BackgroundProperty As DependencyProperty// This API is not available in Javascript.
The identifier for the Background dependency property.
BorderBrush BorderBrush BorderBrush BorderBrush
Gets or sets the Brush that is applied to the edge area of the Border.
public : Brush BorderBrush { get; set; }public Brush BorderBrush { get; set; }Public ReadWrite Property BorderBrush As Brush// This API is not available in Javascript.
<Border BorderBrush="{StaticResource resourceName}"/>
The brush that fills the border. The default is null, (a null brush) which is evaluated as Transparent for rendering.
Examples
This example shows how to set the BorderBrush value to a solid color using an inline-defined attribute value "Blue". The XAML parser uses this "Blue" value to refer to the named color Colors.Blue, and to create the SolidColorBrush instance that supplies the runtime value.
<Border BorderThickness="5" BorderBrush="Blue" >
<StackPanel Grid.Column="0" Grid.Row="0">
<TextBlock Text="One"/>
<TextBlock Text="Two"/>
<TextBlock Text="Three"/>
</StackPanel>
</Border>
Remarks
The BorderThickness value must be greater than 0 in order to see the BorderBrush value take effect.
- See Also
BorderBrushProperty BorderBrushProperty BorderBrushProperty BorderBrushProperty
Identifies the BorderBrush dependency property.
public : static DependencyProperty BorderBrushProperty { get; }public static DependencyProperty BorderBrushProperty { get; }Public Static ReadOnly Property BorderBrushProperty As DependencyProperty// This API is not available in Javascript.
The identifier for the BorderBrush dependency property.
BorderThickness BorderThickness BorderThickness BorderThickness
Gets or sets the thickness of the border.
public : Thickness BorderThickness { get; set; }public Thickness BorderThickness { get; set; }Public ReadWrite Property BorderThickness As Thickness// This API is not available in Javascript.
<Border BorderThickness="uniform"/>
- or -
<Border BorderThickness="left&right,top&bottom"/>
- or -
<Border BorderThickness="left,top,right,bottom"/>
The thickness of the border, in pixels. The default is 0 on all four sides.
- See Also
BorderThicknessProperty BorderThicknessProperty BorderThicknessProperty BorderThicknessProperty
Identifies the BorderThickness dependency property.
public : static DependencyProperty BorderThicknessProperty { get; }public static DependencyProperty BorderThicknessProperty { get; }Public Static ReadOnly Property BorderThicknessProperty As DependencyProperty// This API is not available in Javascript.
The identifier for the BorderThickness dependency property.
Child Child Child Child
Gets or sets the child element to draw the border around.
public : UIElement Child { get; set; }public UIElement Child { get; set; }Public ReadWrite Property Child As UIElement// This API is not available in Javascript.
<Border>
singleChild
</Border>
ChildTransitions ChildTransitions ChildTransitions ChildTransitions
Gets or sets the collection of Transition style elements that apply to child content of a Border.
public : TransitionCollection ChildTransitions { get; set; }public TransitionCollection ChildTransitions { get; set; }Public ReadWrite Property ChildTransitions As TransitionCollection// This API is not available in Javascript.
<Border>
<Border.ChildTransitions>
<TransitionCollection>
oneOrMoreTransitions
</TransitionCollection>
</Border.ChildTransitions>
</Border>
The strongly typed collection of Transition style elements.
Remarks
Important
The XAML syntax for all properties that use a TransitionCollection value is unusual in that you must declare an explicit TransitionCollection object element as the value, and then provide object elements as child elements of TransitionCollection for each of the transition animations you want to use. For most other XAML collection properties you could omit the collection object element because it can be implicit, but properties that use TransitionCollection don't support the implicit collection usage. For more info on implicit collections and XAML, see XAML syntax guide.
Transition animations play a particular role in UI design of your app. The basic idea is that when there is a change or transition, the animation draws the attention of the user to the change.
It's not common to set the value of the ChildTransitions property directly on a Border that is a direct element of app UI. It's more common to have a transitions collection be a part of a visual state, template or style. In this case you use mechanisms such as Setter of a Style to specify the ChildTransitions property. Styles are typically stored as a XAML resource.
- See Also
ChildTransitionsProperty ChildTransitionsProperty ChildTransitionsProperty ChildTransitionsProperty
Identifies the ChildTransitions dependency property.
public : static DependencyProperty ChildTransitionsProperty { get; }public static DependencyProperty ChildTransitionsProperty { get; }Public Static ReadOnly Property ChildTransitionsProperty As DependencyProperty// This API is not available in Javascript.
The identifier for the ChildTransitions dependency property.
CornerRadius CornerRadius CornerRadius CornerRadius
Gets or sets the radius for the corners of the border.
public : CornerRadius CornerRadius { get; set; }public CornerRadius CornerRadius { get; set; }Public ReadWrite Property CornerRadius As CornerRadius// This API is not available in Javascript.
<Border CornerRadius="uniformRadius"/>
- or -
<Border CornerRadius="topLeft,topRight,bottomRight,bottomLeft"/>
The degree to which the corners are rounded, expressed as values of the CornerRadius structure.
Remarks
Member components of a CornerRadius value cannot be negative.
CornerRadiusProperty CornerRadiusProperty CornerRadiusProperty CornerRadiusProperty
Identifies the CornerRadius dependency property.
public : static DependencyProperty CornerRadiusProperty { get; }public static DependencyProperty CornerRadiusProperty { get; }Public Static ReadOnly Property CornerRadiusProperty As DependencyProperty// This API is not available in Javascript.
The identifier for the CornerRadius dependency property.
- See Also
Padding Padding Padding Padding
Gets or sets the distance between the border and its child object.
public : Thickness Padding { get; set; }public Thickness Padding { get; set; }Public ReadWrite Property Padding As Thickness// This API is not available in Javascript.
The dimensions of the space between the border and its child as a Thickness value. Thickness is a structure that stores dimension values using pixel measures.
Remarks
A related property is Margin (a property of FrameworkElement ). For more info about the relationship between margin and padding, see Alignment, margin, and padding or Define layouts with XAML.
- See Also
PaddingProperty PaddingProperty PaddingProperty PaddingProperty
Identifies the Padding dependency property.
public : static DependencyProperty PaddingProperty { get; }public static DependencyProperty PaddingProperty { get; }Public Static ReadOnly Property PaddingProperty As DependencyProperty// This API is not available in Javascript.
The identifier for the Padding dependency property.