IDesktopWindowXamlSourceNative::AttachToWindow method (windows.ui.xaml.hosting.desktopwindowxamlsource.h)

Attaches the current IDesktopWindowXamlSourceNative instance to a parent UI element in your desktop app that is associated with a window handle.

Syntax

HRESULT AttachToWindow(
  HWND parentWnd
);

Parameters

parentWnd

Type: HWND

The window handle of the parent UI element in which you want to host a WinRT XAML control.

Return value

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

For a code example that demonstrates how to use this method, see XamlBridge.cpp in the SampleCppApp sample in the XAML Island samples repo.

Important

Make sure that your code calls the AttachToWindow method only once per DesktopWindowXamlSource object. Calling this method more than once for a DesktopWindowXamlSource object could result in a memory leak.

Requirements

   
Minimum supported client Windows 10, version 1903 (build 18362)
Header windows.ui.xaml.hosting.desktopwindowxamlsource.h

See also

Using the UWP XAML hosting API in a C++ desktop (Win32) app