Share via


WindowsXamlManager Class

Definition

Represents the WinUI XAML framework in a non-Windows App SDK (WASDK) desktop application (for example, a WPF or Windows Forms application).

public ref class WindowsXamlManager sealed : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class WindowsXamlManager final : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class WindowsXamlManager : System.IDisposable
Public NotInheritable Class WindowsXamlManager
Implements IDisposable
Inheritance
Object Platform::Object IInspectable WindowsXamlManager
Attributes
Implements

Examples

This sample shows how to add a WASDK island with XAML content to a Win32 app (the Windows App SDK runtime must be installed for the app to run).

Simple Island App

Remarks

WindowsXamlManager is part of the Windows App SDK XAML hosting API. This API enables non-WASDK desktop applications to host any control that derives from Microsoft.UI.Xaml.UIElement in a UI element that is associated with a window handle (HWND). This API can be used by desktop applications built using WPF, Windows Forms, and the Windows API (Win32).

Changes from WinAppSDK 1.4 to WinAppSDK 1.5

WinAppSDK 1.4 WinAppSDK 1.5 and later
The XAML runtime shuts down asynchronously on a thread when all the WindowsXamlManager and DesktopWindowXamlSource objects on that thread have been closed or destroyed, or the DispatcherQueue running on that thread is shut down. The XAML runtime shuts down on a thread only when the DispatcherQueue on the thread shuts down.
WindowsXamlManager.InitializeForCurrentThread returns a new object each time it is called. WindowsXamlManager.InitializeForCurrentThread returns the same WindowsXamlManager instance until the DispatcherQueue on the thread shuts down.

Methods

Close()

Closes and asynchronously releases any resources used by this WindowsXamlManager.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

GetForCurrentThread()

Gets the WindowsXamlManager object associated with the current thread, if any.

InitializeForCurrentThread()

Initializes the WinUI XAML framework in a non-Windows App SDK (WASDK) desktop application (for example, a WPF or Windows Forms application) on the current thread.

Events

XamlShutdownCompletedOnThread

Occurs when the XAML runtime has finished its shutdown process on the current thread.

Applies to

See also