title: Guides for using WinUI with C++
body: <p>I'll try to summarize my issue as concisely as I can:</p>
  
  <ul>
  <li>I have a legacy C++ project that uses WinAPI to create and manage UI elements. I want to replace this with a more modern framework that supports OOP and has some kind of visual designer. I intend to achieve this by gradually replacing the old WinAPI-based code with the new framework (e.g I could introduce a new popup window that uses the new framework, while the rest of the UI would still use the old window procedures and whatnot)</li>
  <li>My initial plan was to use Qt, since it allows me to conveniently wrap UI code in objects, which I can easily instantiate and manage. It also has a Designer that lets me create custom UI elements (including automatic layout management), a Visual Studio extension, and in general, past experience has shown me that Qt would suit my purposes quite well. However, users here have warned me that it does not cooperate well with WinAPI, and I would basically have to rebuild the app from scratch.</li>
  <li>It was suggested that I use WinUI instead, i.e XAML coupled with C++/WinRT, as these supposedly offer the same flexibility as what I described above. I managed to successfully replicate the results of the <a href="https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/host-standard-control-with-xaml-islands-cpp" rel="noreferrer">"host UWP control in a Win32 app"</a> guide, but there seems to be little useful material beyond that.</li>
  <li>The Microsoft documentation is rather difficult to navigate in order to get a clear answer. At the moment, the guide above is leading me to believe that I'd still be stuck with using WinAPI, as there doesn't seem to be an obvious way to wrap UI code in objects, preferably those that I can derive from existing base classes (e.g some kind of basic Window object)</li>
  </ul>
  
  <p>I have the following environment to work with:</p>
  
  <ul>
  <li>Latest C++ feature level supported by MSVC</li>
  <li>Visual Studio 2019</li>
  <li>Windows 10 (i.e I don't mind if I'm no longer compatible with Windows operating systems)</li>
  </ul>
  
  <p>What I need:</p>
  
  <ul>
  <li><p>An explicit answer on whether it is possible to work with XAML and C++/WinRT in a similar fashion to how one designs UI code in Qt with C++. Exact parity is not necessary, I just want to eliminate the hassle of managing UI using WinAPI, where I practically have to do everything "by hand"</p></li>
  <li><p>If the above is true, then where can I find guides for the various steps of the workflow? How do I make a "window object", how can I design a window with layout management, how do I handle UI events, etc.?</p></li>
  <li><p>Are the above equally possible if it needs to be done in the context of a legacy WinAPI application that I am trying to upgrade?</p></li>
  </ul>