

The following XAML example shows how to draw a border around a Label: Īlternatively, the StrokeShape property value can be specified using property tag syntax: Then, set its child to the control to which the border should be added. To draw a border, create a Border object and set its properties to define its appearance. Therefore, open shapes such as Line are unsupported.įor more information about the properties that control the shape and stroke of the border, see Shapes. When creating a border using a shape, such as a Rectangle or Polygon, only closed shapes should be used. These properties are backed by BindableProperty objects, which means that they can be targets of data bindings, and styled. The default value of this property is 10.0. StrokeMiterLimit, of type double, specifies the limit on the ratio of the miter length to half the stroke thickness.The default value of this property is PenLineJoin.Miter. StrokeLineJoin, of type PenLineJoin, specifies the type of join that is used at the vertices of the stroke shape.The default value of this property is PenLineCap.Flat. StrokeLineCap, of type PenLineCap, describes the shape at the start and end of its line.The default value of this property is 0.0. StrokeDashOffset, of type double, specifies the distance within the dash pattern where a dash begins.StrokeDashArray, of type DoubleCollection, which represents a collection of double values that indicate the pattern of dashes and gaps that make up the border.The default value of this property is 1.0. StrokeThickness, of type double, indicates the width of the border.Stroke, of type Brush, indicates the brush used to paint the border.Therefore, a Border will be rectangular by default. This property has a type converter applied to it that can convert a string to its equivalent IShape. StrokeShape, of type IShape, describes the shape of the border.Padding, of type Thickness, represents the distance between the border and its child element.This property is the ContentProperty of the Border class, and therefore does not need to be explicitly set from XAML. Content, of type IView, represents the content to display in the border.

For more information about layouts, see Layouts. If you want to put a border around multiple objects, wrap them in a container object such as a layout. A Border can only contain one child object. NET Multi-platform App UI (.NET MAUI) Border is a container control that draws a border, background, or both, around another control.
