Table of Contents

Class WindowControlExtensions

Namespace
SharpConsoleUI.Extensions
Assembly
SharpConsoleUI.dll

Extension methods for IWindowControl.

public static class WindowControlExtensions
Inheritance
WindowControlExtensions
Inherited Members

Methods

GetParentWindow(IWindowControl)

Gets the parent Window by walking up the container hierarchy. Returns null if the control is not attached to a window.

public static Window? GetParentWindow(this IWindowControl control)

Parameters

control IWindowControl

The control to find the parent window for.

Returns

Window

The parent Window, or null if not attached to a window.

GetPortalAncestor(IWindowControl)

Finds the nearest PortalContentBase ancestor by walking the container chain, then falling back to the static portal focus registry (for PortalContentBase subclasses where the child's Container chain doesn't include the portal).

public static PortalContentBase? GetPortalAncestor(this IWindowControl control)

Parameters

control IWindowControl

Returns

PortalContentBase

RequestFocus(IFocusableControl, FocusReason)

Requests keyboard focus for this control via the owning window's FocusManager. Works for controls inside portals, panels, and any container depth. No-op if the control is not attached to a window.

public static void RequestFocus(this IFocusableControl control, FocusReason reason = FocusReason.Programmatic)

Parameters

control IFocusableControl

The control to focus.

reason FocusReason

The reason for the focus change. Defaults to Programmatic.