Skip to content

Latest commit

 

History

History
28 lines (18 loc) · 2.01 KB

desktopwindowxamlsource.md

File metadata and controls

28 lines (18 loc) · 2.01 KB
-api-id -api-type ms.custom
T:Windows.UI.Xaml.Hosting.DesktopWindowXamlSource
winrt class
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).

-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.

Because DesktopWindowXamlSource derives from IClosable, so it is recommended that you Close it (Dispose it in .NET) when you’re finished with it.

-see-also

Using the UWP XAML hosting API in a desktop application

-examples