Windows.UI.Xaml.Controls.Border

July 12, 2022 ยท View on GitHub

-description

Draws a border, background, or both, around another object.

-xaml-syntax

<Border>
  singleChild
</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.

A border around 2 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.

Version history

Windows versionSDK versionValue added
180917763BackgroundSizing
180917763BackgroundTransition

-examples

[!div class="nextstepaction"] Open the WinUI 2 Gallery app and see the Border in action

The WinUI 2 Gallery app includes interactive examples of most WinUI 2 controls, features, and functionality. Get the app from the Microsoft Store or get the source code on GitHub.

[!code-xamlBasicBorderXAML]

[!code-xamlLayoutOvwBorder]

-see-also

FrameworkElement, Alignment, margin, and padding