Take a look at all the different methods being built for desktops today. Choose your life partner wisely.

Congratulations. If you read this article in 2021, you have traveled to next year. The global pandemic is over and the world is returning to normal. For developers on the Microsoft stack,. NET 6,. NET MAUI and related tools were launched in November last year (haha, the plan cannot keep up with the changes. The webmaster reprinted this article on May 6, 2022. So far, Maui has not released an official version, but I believe it will be soon, haha). Apple has consolidated macOS Monterey and iOS 15 with stable versions of XCode. If your task today was to launch a brand new desktop application project, what would you use?
First, don't let anyone tell you that desktop applications are "legacy"-look around and you'll see that most corporate workflows rely on desktop software.
It's 2022, and developers have many choices in how to build for the desktop. Depending on who you talk to, the plethora of technologies and options is either liberating or intimidating. Ultimately, this may depend on the developer experience and what else you are building to better share code.
Let's explore the technology stack of desktop applications--from the perspective of three types of developers.
1. the traditionalists
Designed specifically for the desktop, using native tools, and targeting one platform.

1.1 WinForms
Windows Forms于 2002 年随 .NET 1.0 一起推出,是最古老的 Windows 桌面技术之一——令人惊讶的是,它仍然很强大。WinForms 成功的部分原因在于工具的简单性、开发人员的高生产力和丰富的工具生态系统。Windows 上的现代 WinForms 应用程序可以在最新的 .NET 运行时上运行,具有强大的 UI 和对最新 Windows API 的完全访问权限。
1.2 WPF
Windows Presentation Foundation于 2006 年与 .NET 3.0 一起作为 Windows 桌面技术推出,并且还引入了用可扩展应用程序标记语言 (XAML) 定义的可与业务逻辑分离的 UI 堆栈。毫不奇怪,WPF 在最新的 .NET 运行时上运行并且仍然很强大,同时拥有丰富的开发人员生态系统。现代 WPF 应用程序具有深入的系统集成和最新的触摸/墨迹支持,并散发出现代 UX。尽管有一点学习曲线,但 WPF 使开发人员能够提高工作效率并提供一盘丰富的工具。
1.3 UWP
随着 .NET C#/VB/F# 等现代语言的发展,将 .NET 与 XAML 结合用于 UI 标记的趋势在 Windows 8 和 Windows 10 中继续存在。现代需要各种 Windows 设备外形——平板电脑、计算机、2 合一、HoloLens、Surface Hub、Xbox、物联网等。Universal Windows Platform承诺将开发人员体验结合起来,为所有具有自适应 UI 的 Windows 设备构建,并通过 Microsoft Store 提供应用程序。
Subsequent development such as Desktop Bridge allows developers to package their older Win32 applications in UWP containers for release to the app store and the ability to embed modern UWP UIs into other Windows desktop applications through XAML Island. While the original UWP vision may have evolved, the foundation of native runtime and separate API access layers serves Windows applications well today.
1.4 AppKit/Cocoa
想要为 macOS 构建原生桌面应用程序吗?AppKit是你的朋友——定义你需要的所有对象来实现制作 macOS 应用程序的 UI 组件以及在屏幕上有效绘制的细节。AppKit 已融入 Cocoa(macOS 的 Objective-C API 框架)中,但 AppKit 也可以从 SwiftUI 中使用。借助 XCode 中的现代工具,为 macOS 桌面构建只是 iOS 和其他 Apple 平台之外的另一个目标。
2. the reformists
Future-oriented desktop building, understanding cross-platform requirements, and wanting code sharing.

2.1 WinUI 3
Windows UI Library(WinUI)是用于 Windows 桌面和应用程序 UWP 土生土长的用户体验(UX)的框架。WinUI 3 是下一代原生 Windows UI 堆栈,它与 Windows 10 分离,并将 Fluent Design System 融入所有体验中,以实现一致、直观和可访问的 UX。WinUI 3 为开发人员提供了对桌面和 UWP 应用程序的最新工具和支持。Windows 应用 SDK 提供了一组统一的 API 和工具,可供任何桌面应用以一致的方式使用,适用于广泛的目标 Windows 10 和更高版本的操作系统版本。
2.2 Mac Catalyst
It turns out that most developers want to build for iOS and downgrade native macOS development to cater to a niche audience. Apple hopes to solve this problem with Mac Catalyst-making iOS, especially iPad apps, work seamlessly on macOS. Mac and iPad apps can now share the same project/source code with XCode. There is a seamless mapping between AppKit and UIkit, and the visual interface is optimized for touch on iOS and keyboard/mouse on macOS.
2.3 Flutter
Flutter 在跨平台移动开发中越来越受欢迎——在 Dart 中编写代码并使用小部件在屏幕上绘制像素。Flutter 现在可用于制作面向桌面的跨平台应用程序——Flutter 引擎可以为 Windows、Linux 或 macOS 呈现 UI。虽然对 Flutter 的桌面支持仍处于测试阶段(2022 年 5 月 6 日这天,Flutter 的桌面版本已经正式发布几个月了,可放心使用),但开发人员可以从单个代码库针对 Windows UWP、macOS 和 Linux,并能够为现有 Flutter 应用程序添加桌面支持。
2.4. NET MAUI Desktop
对于 .NET 开发人员,Xamarin.Forms 长期以来一直是制作跨平台应用程序的最简单方法之一,但 Xamarin.Forms 主要迎合 iOS/Android 移动平台。虽然有面向桌面的 Xamarin.Forms 呈现器,但开发人员对面向桌面的信心不大。随着 Xamarin.Forms 向.NET MAUI的演变,这种情况发生了变化。
In addition to iOS/Android,. NET MAUI also fully supports desktop platforms-Windows and macOS. What inspires developer confidence in. NET MAUI is that desktop platform support is first-class, with exquisite tools and shared application architecture from a single VS project. Instead of reinventing the wheel, NET MAUI chose to render native UI on the desktop through two widely accepted technologies-WinUI 3 for Windows and Mac Catalyst for macOS.
2.5 Uno platform
对于真正想要使用“Windows”XAML 标记进行跨平台的 .NET 开发人员,Uno Platform提供了一个不错的开源替代方案。为了让 WinUI 无处不在,Uno 平台可以为 Windows、macOS 和 Linux 上的桌面应用程序提供支持——所有这些都来自 C# 和 XAML 的单一代码库和首选 IDE。
2.6 Avalonia
被吹捧为 .NET XAML 框架的Avalonia提供了另一个开源选项,其中包含基于 XAML 的渲染器,可以为桌面平台(Windows、macOS 和 Linux)上的应用程序提供支持。
3. trendsetter
Create desktop applications using non-desktop technologies and think the web is everywhere.

3.1 PWAs
如果使用任何一个 web SPA 框架来构建 web 应用程序,那么PWA Progressive web apps 是让相同的应用程序在桌面上运行的最容易实现的成果之一。PWA 提供对开放式 web 技术的访问,以实现跨平台的互操作性,并为用户提供为其移动或桌面设备定制的类似应用程序的体验。PWA 本质上是一种网站,经过逐步增强,其功能与支持平台上安装的应用程序类似,通常具有脱机工作、支持推送通知和硬件访问等桌面功能。
从常规的 web 应用开始,开发人员可以选择让他们的应用渐进式发展,添加设备功能的应用程序清单文件和后台线程操作的 JavaScript 服务人员。像PWA Builder这样的解决方案使这种转换易于开始,开发人员可以深入进行 Windows/Mac 桌面集成。
3.2 Electron
希望看到在桌面上运行的 web 应用程序并不是什么新鲜事。进入满足此类需求的最普遍的解决方案——Electron。ElectronJS是一个开源项目,用于使用 Web 技术构建跨平台应用程序,并且可以针对任何桌面——Windows、Mac OS 和 Linux。
Many of the most commonly used desktop applications are essentially web applications encapsulated in an Electron shell, such as Visual Studio Code, Microsoft Teams, Slack, and Figma.
Electron has been around for some time and has gained credibility from a strong developer community/ecosystem. Most modern web applications written using the JavaScript SPA framework or. NET/Blazor can use Electron to support desktop solutions. At the heart of Electron's advantages as a shell for hosting web applications is the idea of a stable and predictable environment.
To this end, each Electron app comes bundled with two things that provide reliability-its own copy of the Chromium engine for rendering consistency and the Node.js runtime. While developers should be aware of their application size/memory footprint, Electron has been hands-on tested and provides developers with a wide range of APIs for deep native desktop integration.
3.3 Blazor Hybrid
If we assume a stable computing environment and the existence of modern browsers today, then Web applications might be hosted on the desktop through lightweight WebView-creating a smaller footprint and making it easier to boot the application.
With Blazor, developers can use C #/. NET to build modern web applications that run on the server or run entirely on the client through WebAssembly. Blazor is very popular with modern. NET developers, and it is natural to want to see Blazor's powerful desktop solutions.
借助 .NET 6,.NET MAUI 可以提供完美的引导,使Blazor 混合应用程序能够通过现代 WebView(Windows 上的 WebView 2 和 macOS 上的 WKWebView)在桌面上运行。Blazor 可用于构建真正的本机或混合跨平台应用程序,从而邀请 .NET Web 开发人员进入桌面领域。Blazor 组件模型、Razor 渲染引擎、CSS 样式和可扩展性的熟悉性现在可以应用于构建桌面应用程序,同时与 Web 共享代码。
a better future
Whether you like it or not, the desktop will continue to exist. Desktop applications will continue to power many corporate workflows, and developers will have to build solutions for Windows/MacOS/Linux desktops. The good news is that there are many options about how to get to the desktop-traditional desktop technology coexist happily with Web or cross-platform solutions, allowing for more code sharing. Just like a good parent, a desktop doesn't judge-it's up to you. Good bread is good bread-no matter how you serve it.