何謂通用 Windows 平台 (UWP) app?What's a Universal Windows Platform (UWP) app?

通用 Windows 平台應用程式在各種裝置上執行、 支援調適性使用者介面、 自然的使用者輸入、 一個存放區、 合作夥伴中心和雲端服務

UWP app:A UWP app is:

  • 安全:UWP 應用程式宣告的裝置資源和其存取的資料。Secure: UWP apps declare which device resources and data they access. 使用者必須授權該存取。The user must authorize that access.
  • 能在任何執行 Windows 10 的裝置上使用一般的 API。Able to use a common API on all devices that run Windows 10.
  • 可以使用裝置特定的功能,以及配合不同的裝置螢幕大小、解析度與 DPI 調整 UI。Able to use device specific capabilities and adapt the UI to different device screen sizes, resolutions, and DPI.
  • 在所有執行 Windows 10 的裝置 (或只有您指定的裝置) 上,可從 Microsoft Store 提供。Available from the Microsoft Store on all devices (or only those that you specify) that run on Windows 10. Microsoft Store 在您的 App 上提供多種方式賺錢。The Microsoft Store provides multiple ways to make money on your app.
  • 可以安裝和解除安裝,而對電腦無風險或產生「電腦垃圾」。Able to be installed and uninstalled without risk to the machine or incurring "machine rot".
  • 互動:使用動態磚、推播通知和使用者活動,與 Windows 時間軸和 Cortana 接續未完成的部分互動,來使使用者積極參與。Engaging: use live tiles, push notifications, and user activities that interact with Windows Timeline and Cortana's Pick Up Where I Left Off, to engage users.
  • 可以 C#、C++、Visual Basic 與 Javascript 進行程式設計。Programmable in C#, C++, Visual Basic, and Javascript. 對於 UI,使用 XAML、HTML 或 DirectX。For UI, use XAML, HTML, or DirectX.

讓我們更仔細看看這些。Let's look at these in more detail.

安全Secure

UWP app 在資訊清單中宣告他們所需的裝置功能,例如存取麥克風、定位、網路攝影機、USB 裝置、檔案等等。UWP apps declare in their manifest the device capabilities they need such as access to the microphone, location, Webcam, USB devices, files, and so on. 使用者必須認可並授權該存取之後,才能授與 App 能力。The user must acknowledge and authorize that access before the app is granted the capability.

跨所有裝置的通用 API 表面A common API surface across all devices

Windows 10 導入 「 通用 Windows 平台 (UWP) 」,這每一個執行 Windows 10 的裝置上提供常見的應用程式平台。Windows 10 introduces the Universal Windows Platform (UWP), which provides a common app platform on every device that runs Windows 10. UWP 核心 API 在所有 Windows 裝置上是相同的。The UWP core APIs are the same on all Windows devices. 如果您的應用程式只會使用核心 Api,它會在您的目標桌上型個人電腦、 Xbox、 混合實境耳機,無論任何 Windows 10 裝置上執行等等。If your app only uses the core APIs, it will run on any Windows 10 device no matter whether you are targeting a desktop PC, Xbox, Mixed-reality headset, and so on.

以 C++ /WinRT 或 C++ /CX 撰寫的 UWP app 具有屬於 UWP 之 Win32 API 的存取權。A UWP app written in C++ /WinRT or C++ /CX has access to the Win32 APIs that are part of the UWP. 所有 Windows 10 裝置都實作這些 Win32 Api。These Win32 APIs are implemented by all Windows 10 devices.

擴充功能 SDK 會公開特定裝置類型的獨特功能Extension SDKs expose the unique capabilities of specific device types

如果您的目標是通用 API,您的 App 可以在所有執行 Windows 10 的裝置上執行。If you target the universal APIs, your app can run on all devices that run Windows 10. 如果您想要您的 UWP app 利用裝置特定您的 API,您可以做到的。But if you want your UWP app to take advantage of device specific APIs, you can.

擴充功能 SDK 可讓您為不同裝置呼叫特殊的 API。Extension SDKs let you call specialized APIs for different devices. 例如,如果您的 UWP app 的目標是 IoT 裝置,您可以將 IoT 擴充功能 SDK 新增至您的專案,將特定功能瞄準 IoT 裝置。For example, if your UWP app targets an IoT device, you can add the IoT extension SDK to your project to target features specific to IoT devices. 如需新增擴充功能的 SDK 的詳細資訊,請參閱裝置系列概觀中的擴充功能 SDK 一節。For more information about adding extension SDKs, see the Extension SDKs section in Device families overview.

您可以撰寫您的 App,使其按照您所預期只在特定類型的裝置上執行,然後限定其從 Microsoft Store 發佈到僅該類型的裝置。You can write your app so that you expect it to run only on a particular type of device, and then limit its distribution from the Microsoft Store to just that type of device. 或者,您也可以條件式地測試執行階段出現的 API 並據以調整您的 App 行為。Or, you can conditionally test for the presence of an API at runtime and adapt your app's behavior accordingly. 如需詳細資訊,請參閱裝置系列概觀中的撰寫程式碼一節。For more information, see the Writing Code section in Device families overview.

下列影片提供簡短的裝置系列概觀和調適型程式設計:The following video provides a brief overview of device families and adaptive coding:

調適型控制項和輸入Adaptive controls and input

UI 元素因應 App 所執行的螢幕大小和 DPI 來調整它們的版面配置和縮放比例。UI elements respond to the size and DPI of the screen the app is running on by adjusting their layout and scale. UWP app 與多種輸入類型皆配合良好,例如,鍵盤、滑鼠、觸控、手寫筆和 Xbox One 控制器。UWP apps work well with multiple types of input such as keyboard, mouse, touch, pen, and Xbox One controllers. 如果您需要進一步調整您的 UI 以適合特定畫面大小或裝置,新的配置面板和工具可以協助您設計可因應您的 App 所執行的不同裝置和外形規格的 UI。If you need to further tailor your UI to a specific screen size or device, new layout panels and tooling help you design UI that can adapt to the different devices and form factors that your app may run on.

執行 Windows 的裝置

Windows 使用下列功能,協助您讓您的 UI 以多個裝置為目標:Windows helps you target your UI to multiple devices with the following features:

  • 通用控制項與配置面板可協助您針對裝置的螢幕解析度最佳化您的 UI。Universal controls and layout panels help you to optimize your UI for the screen resolution of the device. 例如,按鈕和滑桿等控制項會自動調整以符合裝置螢幕大小與 DPI 密度。For example, controls such as buttons and sliders automatically adapt to device screen size and DPI density. 配置面板可協助您根據螢幕大小調整版面配置。Layout panels help adjust the layout of content based on the size of the screen. 跨裝置針對解析度和 DPI 差異進行彈性縮放比例調整。Adaptive scaling adjusts to resolution and DPI differences across devices.
  • 通用輸入處理可讓您透過觸控、手寫筆、滑鼠或鍵盤,或像是 Microsoft Xbox 控制器的控制器接收輸入。Common input handling allows you to receive input through touch, a pen, a mouse, a keyboard, or a controller such as a Microsoft Xbox controller.
  • 工具會協助您設計可因應不同螢幕解析度的 UI。Tooling that helps you to design UI that can adapt to different screen resolutions.

您的 app UI 的某些層面會跨裝置自動調整。Some aspects of your app's UI will automatically adapt across devices. 不過,您的 app 使用者經驗設計可能需要依據 app 執行所在的裝置進行調整。Your app's user-experience design, however, may need to adapt depending on the device the app is running on. 例如,在小型、手持裝置上執行相片 App 時可調整其 UI,以確保適合單手操作使用。For example, a photo app could adapt its UI when running on a small, handheld device to ensure that usage is ideal for single-handed use. 在桌上型電腦上執行相片 App 時,應該調整 UI 以充分利用額外的螢幕空間。When a photo app is running on a desktop computer, the UI should adapt to take advantage of the additional screen space.

還有一個適用於所有裝置的 Microsoft StoreThere's one store for all devices

整合應用程式存放區提供您的應用程式在 Windows 10 裝置,例如電腦、 平板電腦、 Xbox、 HoloLens、 Surface Hub 和物聯網 (IoT) 裝置上。A unified app store makes your app available on Windows 10 devices such as PC, tablet, Xbox, HoloLens, Surface Hub, and Internet of Things (IoT) devices. 您可以將 App 提交至 Microsoft Store,使其可用於所有類型的裝置,或僅適用於您選擇的裝置。You can submit your app to the store and make it available to all types of devices, or only those you choose. 您在同一個地方提交和管理適用於 Windows 裝置的所有 app。You submit and manage all your apps for Windows devices in one place. 有您想要用 UWP 功能現代化,並在 Microsoft Store 中銷售的 C++ 傳統型應用程式嗎?Have a C++ desktop app that you want to modernize with UWP features and sell in the Microsoft store? 這也沒有問題。That's okay, too.

UWP app 與 Application Insights 整合以進行詳細的遙測和分析,這是一項重要工具,可用以了解您的使用者並提升您的 App。UWP apps integrate with Application Insights for detailed telemetry and analytics—a crucial tool for understanding your users and improving your apps.

從您的 app 獲利Monetize your app

您可以選擇從您的 App 獲利的方式。You can choose how you'll monetize your app. 有數種方法可以利用您的 App 來賺錢。There are a number of ways to make money with your app. 您只需要選擇一個最適合您的方式,例如:All you need to do is choose the one that works best for you, for example:

  • 付費下載是最簡單的選項。A paid download is the simplest option. 只要訂出價格即可。Just name the price.
  • 試用版讓使用者在購買 app 之前先試用,提供比傳統「免費增值」選項更為簡單的可搜尋性和轉換。Trials let users try your app before buying it, providing easier discoverability and conversion than the more traditional "freemium" options.
  • 激勵使用者的銷售價格。Sale prices to incentivize users.
  • 此外,您還可以使用 App 內購買與廣告。In-app purchases and ads are also available.

Microsoft Store 的 App 提供順暢的安裝、解除安裝和升級體驗Apps from the Microsoft Store provide a seamless install, uninstall, and upgrade experience

所有 UWP app 是使用保護使用者、裝置和系統的封裝系統散發。All UWP apps are distributed using a packaging system that protects the user, device, and system. 使用者完全不需要生命安裝 App,因為 UWP app 可以解除安裝,而不會留下任何以 App 建立的文件以外的任何東西。Users never need regret installing an app because UWP apps can be uninstalled without leaving anything behind except the documents created with the app.

App 可以順暢地部署和更新。Apps can be deployed and updated seamlessly. App 封裝可以模組化,讓您能夠隨選下載內容及擴充功能。App packaging can be modularized so that you can download content and extensions on demand.

傳送相關、即時的資訊給您的使用者,並吸引他們更頻繁使用您的 AppDeliver relevant, real-time info to your users to keep them coming back

您有各種不同的方式您的 UWP app 吸引使用者:There are a variety of ways to keep users engaged with your UWP app:

  • 動態磚和鎖定畫面磚可簡單清楚地從您的 App 呈現與內容相關的適當資訊。Live tiles and lock screen tiles that show contextually relevant and timely info from your app at a glance.
  • 推播通知可提供即時的警示吸引使用者的注意。Push notifications that bring real-time alerts to your user’s attention.
  • 使用者活動可讓使用者即使跨裝置也能在您的 App 中接續未完成的部分。User Activities allow users to pick up where they left off in your app, even across devices.
  • 控制中心可組織整理來自您 App 的通知。The Action Center organizes notifications from your app.
  • 背景執行和觸發會在使用者需要您的 App 時讓 App 開始運作。Background execution and triggers bring your app into action when the user needs it.
  • 您的 app 可以使用語音和藍牙 LE 裝置, 來協助使用者與外界互動。Your app can use voice and Bluetooth LE devices to help users interact with the world around them.
  • 整合 Cortana 以新增語音命令功能至您的 App。Integrate Cortana to add voice command capability to your app.

使用您已知的語言Use a language you already know

UWP app 使用 Windows 執行階段,這是作業系統提供的原生 API。UWP apps use the Windows Runtime, the native API provided by the operating system. 這個 API 以 C++ 實作,而且支援在 C#、Visual Basic、C++ 及 JavaScript 語言中使用。This API is implemented in C++ and is supported in C#, Visual Basic, C++, and JavaScript. 撰寫 UWP app 的部分選項包括:Some options for writing UWP apps include:

  • XAML UI 和 C#、VB 或 C++XAML UI and C#, VB, or C++
  • DirectX UI 和 C++DirectX UI and C++
  • JavaScript 和 HTMLJavaScript and HTML

開始設定Get set up

請查看開始設定,下載開始建立 App 所需的工具,然後撰寫第一個 AppCheck out Get set up to download the tools you need to start creating apps, and then write your first app.

設計您的 AppDesign your app

Microsoft 設計系統命名為 Fluent。The Microsoft design system is named Fluent. Fluent Design 系統是一組與最佳做法結合的 UWP 功能,用於建立在所有執行 Windows 裝置類型上都能展現絕佳效能的 App。The Fluent Design System is a set of UWP features combined with best practices for creating apps that perform beautifully on all types of Windows-powered devices. Fluent 體驗從平板電腦到膝上型電腦,從個人電腦到電視等裝置以及虛擬實境裝置均自然流暢。Fluent experiences adapt and feel natural on devices from tablets to laptops, from PCs to televisions, and on virtual reality devices. 如需 Fluent Design 簡介,請參閱適用於 UWP app 的 Fluent Design 系統See The Fluent Design System for UWP apps for an introduction to Fluent Design.

良好的設計是決定您 App 與使用者的互動方式、外觀,以及功能的程序。Good design is the process of deciding how users will interact with your app, in addition to how it will look and function. 使用者經驗在判斷使用者使用您的 app 時有多愉快佔有舉足輕重的地位,因此請不要跳過這個步驟。User experience plays a huge part in determining how happy people will be with your app, so don't skimp on this step. 設計基本知識會為您介紹如何設計通用 Windows 應用程式。Design basics introduces you to designing a Universal Windows app. 請參閱適用於設計人員的通用 Windows 平台 (UWP) app 簡介,以取得設計能讓使用者滿意的 UWP app 的詳細資訊。See the Introduction to Universal Windows Platform (UWP) apps for designers for information on designing UWP apps that delight your users. 開始撰寫程式碼之前,請參閱裝置入門,協助您思考在您要做為目標的所有不同表單係數上使用您的 app 的互動體驗。Before you start coding, see the device primer to help you think through the interaction experience of using your app on all the different form factors you want to target.

除了在不同裝置上的互動之外,計劃您的 app 以納入跨多個裝置工作的好處。In addition to interaction on different devices, plan your app to embrace the benefits of working across multiple devices. 例如:For example:

新增服務Add services

將您的應用程式提交到 Windows 市集Submit your app to the Store

合作夥伴中心可讓您管理和提交所有您在同一個地方的 Windows 裝置的應用程式。Partner Center lets you manage and submit all of your apps for Windows devices in one place. 請參閱發行的 Windows 應用程式和遊戲以了解如何提交您的應用程式,在 Microsoft Store 中的發行集。See Publish Windows apps and games to learn how to submit your apps for publication in the Microsoft Store.

新功能不只簡化程序,同時還讓您更好控制。New features simplify processes while giving you more control. 您在這裡還能找到結合支付詳細資料的詳細分析報告促銷應用程式和吸引客戶的方式,以及更多好用功能。You'll also find detailed analytic reports combined payout details, ways to promote your app and engage with your customers, and much more.

如需更多的簡介資料,請參閱建置適用於 Windows 10 裝置的 Windows 應用程式的簡介For more introductory material, see An Introduction to Building Windows Apps for Windows 10 Devices

其他進階主題More advanced topics

通用 Windows 平台如何與 Windows 執行階段 ApiHow the Universal Windows Platform relates to Windows Runtime APIs

如果您正在建置通用 Windows 平台 (UWP) 應用程式,您就可以取得大量的里程數和從 「 通用 Windows 平台 (UWP) 」 和 「 Windows 執行階段 (WinRT) 」 詞彙視為增加或減少同義的便利性。If you're building a Universal Windows Platform (UWP) app, then you can get a lot of mileage and convenience out of treating the terms "Universal Windows Platform (UWP)" and "Windows Runtime (WinRT)" as more or less synonymous. 但它能夠查看幕後的技術,並判斷只功能有何差異的想法。But it is possible to look under the covers of the technology, and determine just what the difference is between those ideas. 如果您想知道的這最後一節就很適合您。If you're curious about that, then this last section is for you.

Windows 執行階段和 WinRT Api 會進化版的 Windows Api。The Windows Runtime, and WinRT APIs, are an evolution of Windows APIs. 一開始,Windows 程式撰寫透過一般,C 樣式的 Win32 Api。Originally, Windows was programmed via flat, C-style Win32 APIs. 加入 COM Api 的 (DirectX正在明顯的例子)。To those were added COM APIs (DirectX being a prominent example). Windows Form、 WPF、.NET 和 managed 的語言帶自己的寫入 Windows 應用程式和 API 技術自己類別的方式。Windows Forms, WPF, .NET, and managed languages brought their own way of writing Windows apps, and their own flavor of API technology. Windows 執行階段時,實際上,COM 的下一個階段The Windows Runtime is, under the covers, the next stage of COM. 在實際的應用程式二進位介面 (ABI) 層,其根目錄 COM 中的變成可見的。At the actual application binary interface (ABI) layer, its roots in COM become visible. 但是,Windows 執行階段被設計為可從很棒的一組不同的程式設計語言呼叫。But the Windows Runtime was designed to be callable from a great range of different programming languages. 可在每一種語言很自然的方式呼叫。And callable in a way that's very natural to each of those languages. 為了這個目的,存取的 Windows 執行階段可透過所謂的語言投影。To this end, access to the Windows Runtime is made available via what are known as language projections. 沒有 Windows 執行階段語言投影成C#、 到 Visual Basic、 standard c + + 到、 至 JavaScript,依此類推。There is a Windows Runtime language projection into C#, into Visual Basic, into standard C++, into JavaScript, and so on. 此外,一次封裝適當 (請參閱傳統型橋接器),您可以從內建的其中一項很棒的一組應用程式模型的應用程式呼叫 WinRT Api:Win32、.NET、 WinForms 和 WPF。Furthermore, once packaged appropriately (see Desktop Bridge), you can call WinRT APIs from an app built in one of a great range of application models: Win32, .NET, WinForms, and WPF.

而且不用說,您可以呼叫 WinRT Api,從您的 UWP 應用程式。And, of course, you can call WinRT APIs from your UWP app. UWP 是 Windows 執行階段為基礎的應用程式模型。UWP is an application model built on top of the Windows Runtime. UWP 應用程式模型根據技術上來說, CoreApplication,不過可能會根據您選擇的程式設計語言,隱藏詳細資料。Technically, the UWP application model is based on CoreApplication, although that detail may be hidden from you, depending on your choice of programming language. 如本主題也解釋了,值主張觀點來看,從 UWP 本身即可撰寫單一的二進位檔,可以選擇,發行至 Microsoft Store,並執行任何一種很棒的一組裝置外型規格。As this topic has explained, from a value proposition point of view, the UWP lends itself to writing a single binary that can, should you choose, be published to the Microsoft Store and run on any one of a great range of device form factors. UWP 應用程式的裝置範圍而定 UWP Api 的子集,您會限制您的應用程式呼叫,或有條件地呼叫。The device reach of your UWP app depends on the subset of UWP APIs that you limit your app to calling, or that you call conditionally.

希望這一節已成功在描述基礎 Windows 執行階段 Api,以及機制和通用 Windows 平台的商業價值的技術之間的差異。Hopefully, this section has been successful in describing the difference between the technology underlying Windows Runtime APIs, and the mechanism and business value of the Universal Windows Platform.