Table of Contents

Class NativeWindowHost

Namespace
PluginUI
Assembly
PluginUI.dll

Embeds a foreign Win32 window (video surface, WebView2 controller window, third-party view...) into the layout: the window is re-parented to the host window and kept over Bounds (converted to pixels). It is hidden while this element is collapsed or detached, and re-parented when the host window is recreated.

public sealed class NativeWindowHost : UIElement
Inheritance
NativeWindowHost
Inherited Members

Remarks

A native window always paints above the Direct2D content and is not clipped by scrolling containers or covered by popups. The application keeps ownership of the child window (create it, destroy it after removing it here).

Constructors

NativeWindowHost()

Creates an empty native host.

public NativeWindowHost()

NativeWindowHost(nint)

Creates a native host for childWindow.

public NativeWindowHost(nint childWindow)

Parameters

childWindow nint

Properties

ChildWindow

The embedded window handle (0 = none). Changing it hides the previous window.

[Browsable(false)]
public nint ChildWindow { get; set; }

Property Value

nint

PreferredSize

Natural size reported to layouts when no explicit size is set.

public Size PreferredSize { get; set; }

Property Value

Size

Methods

ArrangeOverride(Rect)

Arranges children inside the final bounds.

protected override void ArrangeOverride(Rect bounds)

Parameters

bounds Rect

MeasureOverride(Size)

Natural size of the content for the available size (margins excluded).

protected override Size MeasureOverride(Size available)

Parameters

available Size

Returns

Size

OnAttached()

Called when the element joins a host (subscribe to external events here).

protected override void OnAttached()

OnDetached()

Called when the element leaves its host (unsubscribe here).

protected override void OnDetached()

OnVisibilityChanged()

Called when IsVisible changes.

protected override void OnVisibilityChanged()

Sync()

Re-applies parent, position and visibility (call after moving the window yourself).

public void Sync()