Language
Edit

WindowsXamlHostBase Class

Definition

WindowsXamlHostBase hosts UWP XAML content inside Windows Forms

public abstract class WindowsXamlHostBase : System.Windows.Forms.ContainerControl
type WindowsXamlHostBase = class
    inherit ContainerControl
Public MustInherit Class WindowsXamlHostBase
Inherits ContainerControl
Inheritance
WindowsXamlHostBase
Derived

Constructors

Name Description
WindowsXamlHostBase()

Initializes a new instance of the WindowsXamlHostBase class.

WindowsXamlHostBase(String)

Properties

Name Description
ChildInternal

Gets or sets XAML content for XamlContentHost

DefaultSize

Gets the default size of the control.

DpiScalingRenderTransform

Gets or sets a value indicating whether a render transform is added to the UWP control corresponding to the current dpi scaling factor if scaling is not supported natively by the XAML island

Focused

Gets a value indicating whether this Control currently has focus. Check both the Control's window handle and the hosted Xaml window handle. If either has focus then this Control currently has focus.

MetadataContainer

Gets the current instance of <seealso cref="T:Microsoft.Toolkit.Win32.UI.XamlHost.XamlApplication"></seealso>

Methods

Name Description
Dispose(Boolean)

Clean up hosted UWP XAML content

GetPreferredSize(Size)

Overrides the base class implementation of GetPreferredSize(Size) to provide correct layout behavior for the hosted XAML content.

GetUwpInternalObject()

Exposes ChildInternal without exposing its actual Type.

OnChildSizeChanged(Object, Object)

Responds to UWP XAML's 'SizeChanged' event, fired when XAML content layout has changed. If 'DesiredSize' has changed, re-run Windows Forms layout.

OnHandleCreated(EventArgs)

Raises the HandleCreated event. Assign window render target to UWP XAML content.

OnHandleDestroyed(EventArgs)

Override that disposes the current instance when the parent handle has been destroyed

OnPaint(PaintEventArgs)

Draw a placeholder Rectangle with 'Xaml Content' in Design mode

OnPaintBackground(PaintEventArgs)

Prevent control from painting the background

OnWindowXamlHostSizeChanged(Object, EventArgs)

Event handler for SizeChanged. If the size of the host control has changed, re-run Windows Forms layout on this Control instance.

PreProcessMessage(Message)

In order to handle keyboard accelerators and TAB input, we must give a chance to <seealso cref="T:Windows.UI.Xaml.Hosting.DesktopWindowXamlSource"></seealso> to handle the msg using <seealso cref="M:Microsoft.Toolkit.Win32.UI.XamlHost.IDesktopWindowXamlSourceNative2.PreTranslateMessage(System.Windows.Forms.Message@)"></seealso>

ProcessTabKey(Boolean)

Processes a tab key, ensuring that Xaml has an opportunity to handle the command before normal Windows Forms processing. (Xaml must be notified of keys that invoke focus navigation.)

Select(Boolean, Boolean)

Activates the Windows Forms WindowsXamlHost Control

SetContent(UIElement)

Sets the root UWP XAML element on DesktopWindowXamlSource

UpdateDpiScalingFactor()

Sets a scaling factor based on the current dpi value on the scaling panel

WndProc(Message)

Processes Windows messages for XamlContentHost control window (not XAML window)

Events

Name Description
ChildChanged

Fired when XAML content has been updated

Applies to