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
controlIWindowControlThe 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
controlIWindowControl
Returns
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
controlIFocusableControlThe control to focus.
reasonFocusReasonThe reason for the focus change. Defaults to Programmatic.