.NET Core 3 using WinUI
Asked Answered
J

3

5

With .NET Core 3 in preview, it is possible to create a WinForms or WPF "desktop application" on the .NET Core platform.

Using XAML islands, it is possible to host UWP controls in a WPF application.

Does .NET Core 3 and up directly support the WinUI library? Or is the best practice to start from a WPF application and host the controls (NavigationView etc ...)?

UPDATE

dotnet new winforms and dotnew new wpf will create .net core projects for their respective technologies.

Is the intention (or is it already possible, and if so: how) to also support something like dotnet new uwp, where UWP style controls are "the default" (by referencing the WinUI library) instead of starting from WPF and using XAML islands.

Jordanna answered 12/12, 2018 at 12:1 Comment(2)
I just asked the same question on this recent blog post: devblogs.microsoft.com/dotnet/…Goer
@Goer I've been in contact with Microsoft about this, WinUI support will not be included for the 'near' future (not in 2019 at least).Jordanna
L
3

.NET Core 3 allows you to include the Windows Desktop SDK that contains that WinForms and WPF frameworks. This SDK is not cross-platform, only works on Windows.

XAML Islands v1 allows to host UWP XAML controls in WPF and WinForms in .NET Framework and .NET Core 3. However, in .NET Framework, only the UWP XAML controls that come with the OS are supported. .NET Core 3 doesn't have this limitation; you can host 3rd party controls, regardless are managed (e.g., written in C#) or native (e.g. written in C++/WinRT).

WinUI 2 is a library of UWP controls created by the UWP XAML team too. The quality of these controls is the same as the inbox OS controls. The WinUI 2 controls aren't bound to the latest Windows 10 version (as happening with the inbox OS controls), they run on the 1703 build and above (downlevel support). You can use these WinUI 2 controls inside of a XAML Island in WinForms or WPF .NET Core 3, and not with the .NET Framework so far.

Last but not least, XAML Islands v1 only works on the Windows 10 1903 update, even if the content of the island works on older OS versions.

Some links:

Luciferous answered 1/10, 2019 at 20:33 Comment(1)
For context Miguel is the PM owner at Microsoft for XAML IslandsGreensand
E
2

XAML Islands should be normally supported in .NET Core 3 based WPF app. The difference here is just the runtime platform - normally WPF apps run on top of full .NET Framework, now it is possible to run them on .NET Core 3 as well.

If it does not work, report the issue on WinUI GitHub or CoreFX GitHub. Keep in mind .NET Core 3 is in its first public preview, so this scenario is probably not fully tested yet.

Earflap answered 12/12, 2018 at 12:6 Comment(2)
I guess, and will update the question for clarification, my question is whether a 'dotnet new uwp' type of project will be available in the future. This would eliminate the sandbox UWP limitations yet still provide direct UWP control support.Jordanna
Current version of .NET Core 3 doesnt support XAML Islands, and the Windows community Toolkit that is supposed to enable XAML islands on .NET Core, is not even compatible with .NET Core yet. I would wait for a few more releases from Microsoft and for them to do a better job of the documentation before trying this stuffZela
C
2

Does .NET Core 3 and up directly support the WinUI library?

No. .NET Core is still a cross-platform version of .NET that has no dependency on neither UWP, Windows Forms or WPF. These desktop frameworks are delivered as separate Windows-only components that layer on top of .NET Core.

WinUI (Microsoft.UI.Xaml) is set of UWP controls for the UWP platform that targets uap10.0. dotnet new uwp would create a UWP app that runs on .NET Core and you would be able to consume the Microsoft.UI.Xaml package as usual in such an app. It would still be an UWP app and not a WPF application.

Chekiang answered 12/12, 2018 at 16:18 Comment(2)
'dotnet new uwp' does not exist yet, I'm looking for ways to use the UWP controls in a .NET Core 3 application without going through WPF or WinForms first (ie, without using XAML islands manually).Jordanna
That won't be possible until UWP supports .NET Core 3.Chekiang

© 2022 - 2024 — McMap. All rights reserved.