Class Border
- Namespace
- Icy.UI
- Assembly
- IcyUI.dll
Decorates a single Child element with a background, border brush, and border thickness.
[ContentProperty("Child")]
public class Border : UIElement, INotifyPropertyChanging, IBindingTarget, INotifyPropertyChanged, INotifyFocusChanged, IContainerLayout
- Inheritance
-
Border
- Implements
- Inherited Members
- Extension Methods
Remarks
UIElement itself carries no decoration (only layout: size, margin, padding, alignment, transforms) - wrap an element in Border whenever it needs a background or a drawn border.
Properties
Background
Gets or sets the background brush drawn behind Child.
public IBrush Background { get; set; }
Property Value
- IBrush
The brush used to paint the background. The default is a transparent solid color brush.
BorderBrush
Gets or sets the brush used to paint the border.
public IBrush? BorderBrush { get; set; }
Property Value
BorderThickness
Gets or sets the thickness of the border, and the amount by which Child is inset from ActualBounds.
public Thickness BorderThickness { get; set; }
Property Value
Child
Gets or sets the single element decorated by this Border instance.
public UIElement? Child { get; set; }
Property Value
ContentBounds
Gets the area available to Child, i.e. ActualBounds inset by BorderThickness and Padding.
public Rectangle ContentBounds { get; }
Property Value
Remarks
Background/BorderBrush are unaffected by Padding - they're drawn (in OnRender(IRenderContext)) across this Border's full local bounds, not ContentBounds. Padding only pushes Child in from the border, matching the standard box model (CSS/WPF): the decoration covers the padding band, only the content is inset by it.
Methods
ArrangeContent()
Handles custom arrange logic when overridden in any UIElement instance.
protected override void ArrangeContent()
Remarks
This method is called during the arrange pass to position and size the element's content within its final bounds. The element's position and size are already determined by the layout system and available in the ActualBounds property.
When implementing this method:
- Position child elements within the available space;
- Respect the element's padding when positioning content;
- Handle any content-specific layout requirements;
- Call Arrange() on child elements if needed.
GetVisualChildren()
Enumerates this element's immediate visual children, in paint order (back-to-front), for hit-testing and tree traversal.
protected override IEnumerable<UIElement> GetVisualChildren()
Returns
- IEnumerable<UIElement>
The element's immediate children. The base implementation yields none (a leaf element).
Remarks
Container elements (e.g. Panel, Border) override this to expose their children, in the exact order they're drawn in — HitTest(Vector2) depends on this matching actual paint order, or clicks will target the wrong, visually-obscured element.
MeasureContent()
Handles custom measure logic when overridden in any UIElement instance.
protected override Size MeasureContent()
Returns
Remarks
This method is called during the measure pass to determine the desired size of the element. The returned size should represent the natural size of the element's content, without considering any constraints, margins, or padding.
When implementing this method:
- Return the natural size needed to display the content;
- Do not include padding, margins, or borders in the returned size;
- Consider the content's actual dimensions (e.g., text length, image size);
- Return Empty if the element has no content.
OnRender(IRenderContext)
Handles custom render logic when overridden in any UIElement instance.
protected override void OnRender(IRenderContext context)
Parameters
contextIRenderContextThe context to render with.