Class Border
Draws a border, background, or both, around another object.
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
public class Border : FrameworkElement, IFrameworkElement, IUIElement, IDependencyObject
Examples
You can add a Border to the XAML as follows:
Or in C# (assuming we have a StackPanel Named MyStackPanel):
Border myBorder = new Border();
myBorder.Width = 60;
myBorder.Height = 30;
myBorder.CornerRadius = new CornerRadius(15);
myBorder.Padding = new Thickness(20);
myBorder.Background = new SolidColorBrush(Windows.UI.Colors.Blue);
myBorder.HorizontalAlignment=HorizontalAlignment.Left;
MyStackPanel.Children.Add(myBorder);
Fields
| Improve this Doc View SourceBackgroundProperty
Identifies the Background dependency property.
Declaration
public static readonly DependencyProperty BackgroundProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
BorderBrushProperty
Identifies the BorderBrush dependency property.
Declaration
public static readonly DependencyProperty BorderBrushProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
BorderThicknessProperty
Identifies the BorderThickness dependency property.
Declaration
public static readonly DependencyProperty BorderThicknessProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
CornerRadiusProperty
Identifies the CornerRadius dependency property.
Declaration
public static readonly DependencyProperty CornerRadiusProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
PaddingProperty
Identifies the Padding dependency property.
Declaration
public static readonly DependencyProperty PaddingProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceBackground
Gets or sets the Brush that fills the background of the border.
Declaration
public Brush Background { get; set; }
Property Value
Type | Description |
---|---|
Brush | The brush that fills the background. |
BorderBrush
Gets or sets the Brush that is used to create the border.
Declaration
public Brush BorderBrush { get; set; }
Property Value
Type | Description |
---|---|
Brush | The brush that fills the border. |
BorderThickness
Gets or sets the thickness of the border.
Declaration
public Thickness BorderThickness { get; set; }
Property Value
Type | Description |
---|---|
Thickness |
Child
Gets or sets the child element to draw the border around.
Declaration
public UIElement Child { get; set; }
Property Value
Type | Description |
---|---|
UIElement |
CornerRadius
Gets or sets the radius for the corners of the border.
Declaration
public CornerRadius CornerRadius { get; set; }
Property Value
Type | Description |
---|---|
CornerRadius |
LogicalChildren
Gets an enumerator that can be used to iterate the logical child elements of a Border.
Declaration
protected override IEnumerator LogicalChildren { get; }
Property Value
Type | Description |
---|---|
System.Collections.IEnumerator | An enumerator that can be used to iterate the logical child elements of a Border. |
Overrides
| Improve this Doc View SourcePadding
Gets or sets the distance between the border and its child object.
Declaration
public Thickness Padding { get; set; }
Property Value
Type | Description |
---|---|
Thickness |
VisualChildrenCount
Gets a value that is equal to the number of visual child elements of this instance of Border.
Declaration
protected override int VisualChildrenCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of visual child elements. |
Overrides
Methods
| Improve this Doc View SourceArrangeOverride(Size)
Declaration
protected override Size ArrangeOverride(Size finalSize)
Parameters
Type | Name | Description |
---|---|---|
Size | finalSize |
Returns
Type | Description |
---|---|
Size |
Overrides
| Improve this Doc View SourceCreateDomElement(Object, out Object)
Declaration
public override object CreateDomElement(object parentRef, out object domElementWhereToPlaceChildren)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parentRef | |
System.Object | domElementWhereToPlaceChildren |
Returns
Type | Description |
---|---|
System.Object |
Overrides
| Improve this Doc View SourceGetVisualChild(Int32)
Gets the child UIElement element at the specified index position.
Declaration
protected override UIElement GetVisualChild(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index position of the child element. |
Returns
Type | Description |
---|---|
UIElement | The child element at the specified index position. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | index is greater than the number of visual child elements. |
INTERNAL_OnAttachedToVisualTree()
Declaration
protected override void INTERNAL_OnAttachedToVisualTree()
Overrides
| Improve this Doc View SourceMeasureOverride(Size)
Declaration
protected override Size MeasureOverride(Size availableSize)
Parameters
Type | Name | Description |
---|---|---|
Size | availableSize |
Returns
Type | Description |
---|---|
Size |