构建 Windows 电脑的桌面应用Build desktop apps for Windows PCs

本文提供了开始构建适合 Windows 的桌面应用或更新现有桌面应用以在 Windows 10 中采用最新体验所需的信息。This article provides the info you need to get started building desktop apps for Windows or updating existing desktop apps to adopt the latest experiences in Windows 10.

适合桌面应用的平台Platforms for desktop apps

有 4 个主要平台可用于构建适合 Windows 电脑的桌面应用。There are four main platforms for building desktop apps for Windows PCs. 每个平台都提供定义应用生命周期的应用模型和一组完整的 UI 控件,你还可在平台上访问一组全面的托管或本机 API,它们可用来使用 Windows 功能。Each platform provides an app model that defines the lifecycle of the app, a complete set of UI controls, and access to a comprehensive set of managed or native APIs for using Windows features.

下表介绍了这些平台。The following table introduces the platforms. 要对这些平台进行深入比较并了解适合每个平台的其他资源,请参阅选择应用平台For an in-depth comparison of these platforms along with additional resources for each platform, see Choose your app platform.


平台Platform 描述Description 文档和资源Docs and resources
通用 Windows 平台 (UWP)Universal Windows Platform (UWP)

适合 Windows 10 应用和游戏的领先平台。The leading-edge platform for Windows 10 apps and games. 可构建仅使用 UWP 控件和 API 的 UWP 应用,也可在桌面应用中使用 UWP 控件和 API,这些应用根据设计可使用其他平台之一。You can build UWP apps that exclusively use UWP controls and APIs, or you can use UWP controls and APIs in desktop apps that are built using one of the other platforms.

开始行动Get started
API 参考API reference
示例Samples
Win32Win32

适合需要直接访问 Windows 和硬件的本机 C/C++ Windows 应用的首选平台。The platform of choice for native C/C++ Windows apps that require direct access to Windows and hardware.

开始行动Get started
API 参考API reference
示例Samples
WPFWPF

已建立的基于 .NET 的平台,它适合带有 XAML UI 模型的图形丰富的托管 Windows 应用。The established .NET-based platform for graphically-rich managed Windows apps with a XAML UI model. 这些应用可面向 .NET Core 3 或完整的 .NET Framework。These apps can target .NET Core 3 or the full .NET Framework.

开始行动Get started
API 参考 (.NET)API reference (.NET)
示例Samples
Windows 窗体Windows Forms

基于 .NET 的平台,它专用于具有轻量级 UI 模型的托管业务线应用。A .NET-based platform that is designed for managed line-of-business apps with a lightweight UI model. 这些应用可面向 .NET Core 3 或完整的 .NET Framework。These apps can target .NET Core 3 or the full .NET Framework.

开始行动Get started
API 参考 (.NET)API reference (.NET)
示例Samples

针对 Windows 10 更新现有桌面应用Update existing desktop apps for Windows 10

如果你当前有 WPF、Windows 窗体或本机 Win32 桌面应用,Windows 10 和通用 Windows 平台 (UWP) 提供了很多功能可用来在应用中提供新式体验。If you have an existing WPF, Windows Forms, or native Win32 desktop app, Windows 10 and the Universal Windows Platform (UWP) offer many features you can use to deliver a modern experience in your app. 你可按照自己的进度,在应用中将其中大多数功能用作模块化组件,而不必为其他平台重新编写应用。Most of these features are available as modular components that you can adopt in your app at your own pace without having to rewrite your app for a different platform.

有很多功能可用于增强你的现有桌面应用,下面仅举几例:Here are just a few of the features available to enhance your existing desktop apps:

  • 使用 MSIX 打包和部署桌面应用。Use MSIX to package and deploy your desktop apps. MSIX 是一种新式 Windows 应用包格式,提供适合所有 Windows 应用的通用打包体验。MSIX is a modern Windows app package format that provides a universal packaging experience for all Windows apps. MSIX 汇集了 MSI、.appx、App-V 和 ClickOnce 安装技术的最佳方面,按照安全可靠的目标构建。MSIX brings together the best aspects of MSI, .appx, App-V and ClickOnce installation technologies and is built to be safe, secure, and reliable.
  • 使用包扩展将桌面应用与 Windows 10 体验相集成。Integrate your desktop app with Windows 10 experiences by using package extensions. 例如,将“启动”磁贴指向你的应用,将你的应用设为共享目标,或者通过你的应用发送 toast 通知。For example, point Start tiles to your app, make your app a share target, or send toast notifications from your app.
  • 使用 XAML 孤岛在桌面应用中托管 UWP XAML 控件。Use XAML Islands to host UWP XAML controls in your desktop app. 很多最新 Windows 10 UI 功能仅适用于 UWP XAML 控件。Many of the latest Windows 10 UI features are only available to UWP XAML controls.

有关详细信息,请参阅以下文章。For more information, see these articles.


文章Article 描述Description
实现桌面应用的现代化Modernize desktop apps 介绍可在 WPF、Windows 窗体和 C++ Win32 应用等任何桌面应用中使用的最新 Windows 10 和 UWP 开发功能。Describes the latest Windows 10 and UWP development features you can use in any desktop app, including WPF, Windows Forms, and C++ Win32 apps.
教程:实现 WPF 应用现代化Tutorial: Modernize a WPF app 按照分步说明将 UWP 墨迹和日历控件添加到应用中并将其打包到 MSIX 包中,从而将现有 WPF 业务线示例应用现代化。Follow step-by-step instructions to modernize an existing WPF line-of-business sample app by adding UWP Ink and calendar controls to the app and packaging it in an MSIX package.

创建新的桌面应用Create new desktop apps

如果要新建适合 Windows 的桌面应用,下面有一些资源可帮助你入门。If you are creating a new desktop app for Windows, here are some resources to help get you started.


文章Article 描述Description
选择应用平台Choose your app platform 提供对主要桌面应用的深入比较,并可帮助你选择适合你的需求的平台。Provides an in-depth comparison of the main desktop app platforms and can help you choose the right platform for your needs. 本文还提供了介绍每个平台的文档的有用链接。This article also provides useful links to docs for each platform.
实现桌面应用的现代化Modernize desktop apps 介绍可在 WPF、Windows 窗体和 C++ Win32 应用等任何桌面应用中使用的最新 Windows 10 和 UWP 开发功能。Describes the latest Windows 10 and UWP development features you can use in any desktop app, including WPF, Windows Forms, and C++ Win32 apps.
功能和技术Features and technologies 概要介绍可通过每个主要桌面应用平台和相关文档的链接访问的 Windows 功能。Provides an overview of Windows features that are accessible via each of the main desktop app platforms and links to the related docs.
资源Resource 描述Description
.NET Core 3.0.NET Core 3.0 了解 .NET Core 3.0 的最新功能,包括对 WPF 和 Windows 窗体应用的增强功能。Learn about the latest features of .NET Core 3.0, including enhancements for WPF and Windows Forms apps.
关于 WPF 和 .NET Core 3.0 的桌面指南Desktop guide for WPF and .NET Core 3.0 开发面向 .NET Core 3.0 而不是整个 .NET Framework 的 WPF 应用。Develop WPF apps that target .NET Core 3.0 instead of the full .NET Framework.
AzureAzure 使用 Azure 云服务扩大应用的覆盖范围。Extend the reach of your apps with Azure cloud services.
Visual StudioVisual Studio 了解如何使用 Visual Studio 开发应用和服务。Learn how to use Visual Studio to develop apps and services.
MSIXMSIX 采用新式通用打包格式打包和部署任何 Windows 应用。Package and deploy any Windows app in a modern and universal packaging format.
Windows AIWindows AI 使用 Windows AI 构建智能解决方案来处理应用中的复杂问题。Use Windows AI to build intelligent solutions for complex problems in your apps.
Windows 容器Windows Containers 在运行快速、完全隔离的 Windows 环境中将应用程序与其依赖项打包在一起。Package your applications with their dependencies in fast, fully isolated Windows environments.
渐进式 Web 应用Progressive Web Apps 将 Web 应用转换为可分发并可在 Windows 10 上作为 UWP 应用运行的渐进式 Web 应用。Convert your web apps into Progressive Web Apps that can be distributed and run as UWP apps on Windows 10.
XamarinXamarin 使用 .NET 代码和平台专属用户界面构建适合 Windows,、Android、iOS 和 macOS 的跨平台应用。Build cross-platform apps for Windows, Android, iOS, and macOS using .NET code and platform-specific user interfaces.
Windows 8.x 及更低版本的文档存档Docs archive for Windows 8.x and earlier 访问存档的文档,了解如何构建适合 Windows 8.x 及更低版本的应用。Access archived documentation about building apps for Windows 8.x and earlier versions.