WinUI 3: Any way to retrieve winrt::Microsoft.UI.Xaml::Window from HWND, WindowId or AppWindow?

世杰 倪 40 Reputation points

I created a window through CreateWindowEx in a WinUI 3 application, so I didn't have a Window object at first.

Using the window handle, I'm able to get WindowId and thus AppWindow. However, I couldn't find any document on how to get Window other than declare it directly.

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
508 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 7,106 Reputation points Microsoft Vendor

    There is no existed winrt::Microsoft.UI.Xaml::Window which associates with the native window in your sample.

    Also, there is no APIs to get the associated winrt::Microsoft::UI::Xaml::Window from the native window or WindowId as I said in the question.

    I have submitted a feature request about this. You can also submit an issue at WindowsAPPSDK GitHub Issues.

    0 comments No comments

0 additional answers

Sort by: Most helpful