You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With C++/WinRT adding support for various MinGW toolchains (both Clang/LLVM and GCC), using WinUI with MinGW is now possible.
Modern MinGW toolchains that links to the Universal C Runtime is recommended, also you'll need a toolchain that is relatively new. (GCC 12 and Clang/LLVM 15 from MSYS2 are tested.)
Note there is no working XAML compiler and MIDL 3.0 compiler for MinGW, so certain features will not work. {x:Bind} and initializing custom classes from XAML (like ValueConverters, UserControls) are two examples of that.
There are two points that I wish to add.
First, since MIDL is only used to generate the .winmd file, if you are able to take the licensing then it is possible to use the MIDL and other winmd tools from the Windows SDK. The SDK tools are available in a nuget package, so you don't require installing the entire Windows SDK. If you are able to use C++/WinRT and the Windows App SDK packages, then you are highly likely to be able to use the Windows SDK Build Tools.
Second, the lack of the XAML compiler doesn't mean that you can't use binding, it means that you have to provide the generated code manually. If you use the Visual C++ project as reference, then you can figure out what you need to do in order to support the full metadata provider and binding, but the code is not fun to write.
I actually tried MIDL with MinGW, but I found that the [bindable] attribute is not respected and binding still does not work. There might still be some stuff behind the scenes.
{Binding} is possible if you implement ICustomPropertyProvider in your view model, I did this in both of my samples.
And other XAML features should be possible with an implementation of IXamlMetadataProvider, but I haven't tried that since it looks even harder to write by hand.
From what I can gather, the bindable attribute is used by the Xaml compiler to generate extra binding information in the code generation portion. From the diagnostic logs, it seems like phase 2 of the Xaml compiler generates the metadata provider and supporting source files as well as the Xaml binding files. So I think the bindable attribute is only really used by the Xaml compiler to generate that extra information and doesn't have much of an effect in general in the projection.
But MIDL isn't only used for Xaml binding. As already stated, MIDL in general is used to generate the .winmd files. This means that MIDL is one step in generating WinRT components.
In the WinUI context, IDL isn't that useful if it is not used in XAML though. Sure you can expose your ViewModels as WinRT runtime class, but other than the XAML framework, who is going to use it?
In the WinUI context, IDL isn't that useful if it is not used in XAML though. Sure you can expose your ViewModels as WinRT runtime class, but other than the XAML framework, who is going to use it?
Some APIs (e.g., Frame.Navigate) requires Windows Runtime classes. Because of those APIs, removing MIDL from a WinUI 3 will never come true unless the WinUI 3 team changes the design of the xaml system.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
With C++/WinRT adding support for various MinGW toolchains (both Clang/LLVM and GCC), using WinUI with MinGW is now possible.
Modern MinGW toolchains that links to the Universal C Runtime is recommended, also you'll need a toolchain that is relatively new. (GCC 12 and Clang/LLVM 15 from MSYS2 are tested.)
Note there is no working XAML compiler and MIDL 3.0 compiler for MinGW, so certain features will not work. {x:Bind} and initializing custom classes from XAML (like ValueConverters, UserControls) are two examples of that.
Here are two samples:
System XAML (Windows.UI.Xaml) with XAML islands, but no WinUI 2:

https://github.com/driver1998/XamlMinGW
WinUI 3 / Windows App SDK:

https://github.com/driver1998/WinUI-MinGW
All reactions