Table of Contents

Class PanelControl

Namespace
SharpConsoleUI.Controls
Assembly
SharpConsoleUI.dll

A bordered panel that hosts child controls. Implemented as a permanently non-collapsible CollapsiblePanel: the collapse API is sealed off (the panel is always expanded). Content/SetContent(string) replace all body content with a single borderless MarkupControl child. Container operations (AddControl, RemoveControl, ClearControls, Children), the border/header chrome (BorderColor, Padding, UseSafeBorder), the colour role surface and the mouse events are all inherited from CollapsiblePanel.

public class PanelControl : CollapsiblePanel, IDOMPaintable, INotifyPropertyChanged, IContainer, IContainerControl, IControlHost, IMouseAwareControl, IInteractiveControl, IFocusableControl, IWindowControl, IDisposable, IFocusableContainerWithHeader, ILogicalCursorProvider, IColorRoleableControl
Inheritance
PanelControl
Implements
Inherited Members
Extension Methods

Constructors

PanelControl()

Initializes a new instance of the PanelControl class.

public PanelControl()

PanelControl(string)

Initializes a new instance of the PanelControl class with text content.

public PanelControl(string text)

Parameters

text string

The text to display inside the panel (supports markup).

Properties

BackgroundColor

Gets or sets the background color. When null, the panel inherits from its container. Exposes a Color? contract (callers may write panel.BackgroundColor ?? fallback).

public Color? BackgroundColor { get; set; }

Property Value

Color?

BorderStyle

Gets or sets the border style for the panel. Maps onto the base HeaderStyle: RoundedRounded, DoubleLineDoubleLine, None/ FramelessBorderless, and SingleBordered.

public BorderStyle BorderStyle { get; set; }

Property Value

BorderStyle

Collapsible

Gets or sets whether the panel can be collapsed/expanded by the user. Defaults to true (current behavior). When false the panel is locked expanded, draws no expand/collapse indicator, ignores header clicks and Enter/Space, and is not itself a Tab stop — focus passes through to its body children (the panel behaves as a plain container).

public override sealed bool Collapsible { get; set; }

Property Value

bool

Remarks

Always false for a panel; the setter is a no-op.

Content

Gets or sets the content to display inside the panel (supports markup). Setting this replaces ALL body content with a single borderless MarkupControl child. Setting it to null or empty removes that child.

public string? Content { get; set; }

Property Value

string

ForegroundColor

Gets or sets the foreground color. When null, the panel resolves the foreground from the theme/container. Exposes a Color? contract.

public Color? ForegroundColor { get; set; }

Property Value

Color?

Header

Gets or sets the header text displayed at the top of the panel border. An alias over Title that also toggles header visibility.

public string? Header { get; set; }

Property Value

string

HeaderAlignment

Gets or sets the horizontal alignment of the header text, using TextJustification. Maps onto the base HeaderAlignment (HorizontalAlignment).

public TextJustification HeaderAlignment { get; set; }

Property Value

TextJustification

IsExpanded

Gets or sets whether the body is expanded (visible). Default true.

public override sealed bool IsExpanded { get; set; }

Property Value

bool

Remarks

Always true for a panel; the setter is a no-op.

ShowHeader

Gets or sets whether the header row is drawn. Defaults to true. When false and the panel is non-collapsible, the header is fully suppressed: a borderless panel shows only its body, and a bordered panel draws a clean box (titleless top border) around the body. A collapsible panel always shows its header regardless of this flag (see Collapsible), since the header is the only affordance for toggling it.

public override sealed bool ShowHeader { get; set; }

Property Value

bool

ShowHeaderSeparator

Gets or sets whether a horizontal separator line is drawn beneath a borderless header. Has no effect on the bordered header style. Defaults to false.

public override sealed bool ShowHeaderSeparator { get; set; }

Property Value

bool

WordWrap

Gets or sets whether content lines that exceed the panel width are word-wrapped. When true (default), long lines are broken at word boundaries. When false, long lines are clipped — use this for pre-formatted content such as graphs and progress bars.

public bool WordWrap { get; set; }

Property Value

bool

Methods

Collapse()

Collapses the body, leaving only the header visible.

public override sealed void Collapse()

Remarks

No-op: a panel cannot be collapsed.

Create()

Creates a new builder for configuring a PanelControl.

public static PanelBuilder Create()

Returns

PanelBuilder

A new builder instance.

Expand()

Expands the body.

public override sealed void Expand()

Remarks

No-op: a panel is always expanded.

SetContent(string)

Sets the content to display inside the panel using text (supports markup). Replaces all existing body content.

public void SetContent(string text)

Parameters

text string

The text to display.

Toggle()

Toggles between expanded and collapsed.

public override sealed void Toggle()

Remarks

No-op: a panel cannot be toggled.