Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 2.22 KB

File metadata and controls

29 lines (19 loc) · 2.22 KB
-api-id T:Windows.UI.Xaml.Hosting.DesktopWindowXamlSource
-api-type winrt class
ms.custom RS5, 19H1

Windows.UI.Xaml.Hosting.DesktopWindowXamlSource

-description

Enables a non-UWP desktop application (for example, a WPF or Windows Forms application) to host UWP controls in any UI element that is associated with a window handle (HWND).

Equivalent WinUI class: Microsoft.UI.Xaml.Hosting.DesktopWindowXamlSource.

-remarks

DesktopWindowXamlSource is the main class in the UWP XAML hosting API. This API enables non-UWP desktop applications to host any control that derives from Windows.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). For more information, see Using the UWP XAML hosting API in a desktop application.

If you create a DesktopWindowXamlSource object before you create the Windows.UI.Xaml.UIElement objects that will be hosted in it, the framework for hosting Windows.UI.Xaml.UIElement content makes sure all the objects are initialized to the same thread. If you create the Windows.UI.Xaml.UIElement objects before you create the DesktopWindowXamlSource object in which they will be hosted, you must call WindowsXamlManager.InitializeForCurrentThread before you instantiate the Windows.UI.Xaml.UIElement objects.

DesktopWindowXamlSource derives from IClosable. To avoid a leak that results from a cycle between it and WindowsXamlManager you must call Close (Dispose it in .NET) before you release WindowsXamlManager.

-see-also

Using the UWP XAML hosting API in a desktop application

-examples