Border Class

Definition

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

public class Border : System.Windows.Controls.Decorator
Inheritance
Derived

Inherited Members

System.Object

System.Windows.Controls.Decorator

System.Windows.DependencyObject

System.Windows.FrameworkElement

System.Windows.Media.Visual

System.Windows.Threading.DispatcherObject

System.Windows.UIElement

Examples

The following example demonstrates how to create a Border and set properties in code and Extensible Application Markup Language (XAML).

myBorder = gcnew Border();
myBorder->Background = Brushes::LightBlue;
myBorder->BorderBrush = Brushes::Black;
myBorder->BorderThickness = Thickness(2);
myBorder->CornerRadius = CornerRadius(45);
myBorder->Padding = Thickness(25);
myBorder = new Border();
myBorder.Background = Brushes.LightBlue;
myBorder.BorderBrush = Brushes.Black;
myBorder.BorderThickness = new Thickness(2);
myBorder.CornerRadius = new CornerRadius(45);
myBorder.Padding = new Thickness(25);
Dim myBorder As New Border
myBorder.Background = Brushes.LightBlue
myBorder.BorderBrush = Brushes.Black
myBorder.BorderThickness = New Thickness(2)
myBorder.CornerRadius = New CornerRadius(45)
myBorder.Padding = New Thickness(25)
<Border Background="LightBlue" 
        BorderBrush="Black" 
        BorderThickness="2" 
        CornerRadius="45" 
        Padding="25">

Remarks

Border can have only one child. To display multiple child elements, you need to place an additional Panel element within the parent Border. You can then place child elements within that Panel element.

If you want to display a border around your content, you must place the elements within a parent Border element.

Constructors

Border()

Initializes a new instance of the Border class.

Fields

Background​Property

Identifies the Background dependency property.

Border​Brush​Property

Identifies the BorderBrush dependency property.

Border​Thickness​Property

Identifies the BorderThickness dependency property.

Corner​Radius​Property

Identifies the CornerRadius dependency property.

Padding​Property

Identifies the Padding dependency property.

Properties

Background

Gets or sets the Brush that fills the area between the bounds of a Border.

Border​Brush

Gets or sets the Brush that draws the outer border color.

Border​Thickness

Gets or sets the relative Thickness of a Border.

Corner​Radius

Gets or sets a value that represents the degree to which the corners of a Border are rounded.

Padding

Gets or sets a Thickness value that describes the amount of space between a Border and its child element.

Methods

Arrange​Override(​Size)

Arranges the contents of a Border element.

Measure​Override(​Size)

Measures the child elements of a Border before they are arranged during the ArrangeOverride(Size) pass.

On​Render(​Drawing​Context)

Draws the contents of a DrawingContext object during the render pass of a Border.