Skip to content

How to open a WinUI Window from a WinForms project #4203

Closed Answered by DarranRowe
karmeye asked this question in Q&A
Discussion options

You must be logged in to vote

Well I wrote a quick and dirty C++ example of how to separate things.

wuiinterop.zip

While it is C++ and doesn't use Windows forms, the concept itself works.

There are a couple of notes on this.

First, the WinUI 3 Xaml compiler is enabled. This mean the automatic generation of App and the Window runtime classes is enabled. This is easy to do in the case of the Windows API and most likely WinForms. If you want to do this with WPF then you would likely also need to separate out the WPF or WinUI 3 into a separate library.
Second, the event loops for WinUI 3 and the Windows API are completely independent. The biggest issue this causes is that you must create the windows on the appropriate thr…

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@karmeye
Comment options

Comment options

You must be logged in to vote
6 replies
@DarranRowe
Comment options

@karmeye
Comment options

@DarranRowe
Comment options

@DarranRowe
Comment options

Answer selected by karmeye
@karmeye
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants