Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core 3 using WinUI

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.

like image 441
mathias Avatar asked Dec 12 '18 12:12

mathias


People also ask

Is WinUI dead?

Microsoft will be maintaining WinUI 2. x for UWP apps, but it is obvious that Microsoft will be investing more in WinUI 3. Long story short — UWP is not dead and there are no plans against it, but the company's current priority is WinUI 3 refresh for Win32 apps.

Is WinUI 3 production ready?

WinUI 3 can be used to build production-ready desktop/Win32 Windows apps.

How do I get started with WinUI 3?

In Visual Studio, select File > New > Project. In the New Project dialog's drop-down filters, select C#/C++, Windows, and WinUI, respectively. Select the Blank App, Packaged (WinUI 3 in Desktop) project template, and click Next. That template creates a desktop app with a WinUI 3-based user interface.

Will WinUI replace UWP?

We will replace UWP with WinUI components in our v22. 1 release. UWP controls and demos will be removed from all distributions/installations. We will continue to provide support and minor updates to our UWP controls until December 2022.


2 Answers

.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:

  • Xaml Islands v1 Updates and Roadmap

  • Host a custom UWP control in a WPF app using XAML Islands

like image 133
Miguel Ramos Avatar answered Oct 04 '22 03:10

Miguel Ramos


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.

like image 30
Martin Zikmund Avatar answered Oct 04 '22 05:10

Martin Zikmund