取得 Windows 應用程式範例Get Windows app samples

許多官方 Windows 程式碼範例都可在各種 GitHub 存放庫中取得,包括通用 Windows 平台 (UWP) 應用程式範例Windows 傳統範例,以及 Windows 開發人員文件範例集合。Many official Windows code samples are available in various GitHub repositories, including Universal Windows Platform (UWP) app samples, Windows classic samples, along with a collection of Windows developer documentation samples. 這些範例會示範大部分的 Windows 功能及其 API 使用模式。These samples demonstrate most Windows features and their API use patterns.

GitHub Windows 通用範例存放庫

若要更輕鬆地尋找特定範例,您可以透過範例瀏覽器,瀏覽及搜尋各種 Microsoft 開發人員工具和技術的已分類程式碼範例集合。To make finding specific samples a little bit easier, you can browse and search a categorized collection of code samples for various Microsoft developer tools and technologies through the sample browser.

Microsoft 範例瀏覽器

Windows 開發人員文件範例Windows developer documentation samples

以下是專為支援 Windows 開發人員文件所建立的迷你應用程式範例清單。Here's a list of mini-app samples created specifically to support Windows developer documentation. 除非另有說明,否則下列範例是已更新為使用最新 WinUI 2.4 控制項的所有通用 Windows 平台 (UWP) 應用程式。Unless noted, the following samples are all Universal Windows Platform (UWP) apps that have been updated to use the latest WinUI 2.4 controls.

  • Rss 助讀程式 - 擷取 RSS 摘要及檢視文章Rss Reader - Retrieve RSS feeds and view articles
  • Family Notes (家庭記事本) - 探索不同的輸入形式和使用者感知案例Family Notes - Explore different input modalities and scenarios of user awareness
  • 客戶訂單 - 對企業開發人員有幫助的功能,例如 Azure Active Directory (AAD) 驗證、UI 控制項 (包括資料格)、Sqlite 與 SQL Azure 資料庫整合、Entity Framework 和雲端 API 服務等Customer Orders - Features useful to enterprise developers, like Azure Active Directory (AAD) authentication, UI controls (including a data grid), Sqlite and SQL Azure database integration, Entity Framework, and cloud API services
  • 午餐排程器 - 排程您與朋友和同事共用午餐Lunch Scheduler - Schedule lunches with your friends and coworkers
  • 著色本 - Windows Ink (包括 Windows Ink 工具列) 及星形控制器 (適用於轉盤裝置,例如 Surface Dial) 功能Coloring Book - Windows Ink (including the Windows Ink Toolbar) and radial controller (for Wheel devices such as the Surface Dial) features
  • 網路協助程式 (測驗遊戲) - 網路探索與通訊Network Helper (Quiz Game) - Network discovery and communication
  • HUE 燈光控制器 - 使用 Cortana 和藍牙低功耗 (藍牙 LE) 的智能居家自動化功能HUE Lights Controller - Intelligent home automation with Cortana and Bluetooth Low Energy (Bluetooth LE)
  • Marble Maze (大理石迷宮) - 使用 DirectX 的基本3D 遊戲Marble Maze - Basic 3D game using DirectX
  • PhotoLab - 檢視和編輯影像檔案PhotoLab - View and edit image files

下載程式碼Download the code

若要下載範例,請移至其中一個 Microsoft 存放庫,例如通用 Windows 平台 (UWP) 應用程式範例To download the samples, go to one of the Microsoft repos such as Universal Windows Platform (UWP) app samples. 選取 [Clone or download] (複製或下載),然後選取 [Download ZIP] (下載 ZIP)。Select Clone or download, and then select Download ZIP.

範例下載

範例下載 .zip 檔案一律會有最新範例。The samples download .zip file always has the latest samples. 您不需要 GitHub 帳戶就可以下載該檔案。You don’t need a GitHub account to download the file. 當 SDK 更新發行時或如果您想要挑選任何最近的變更和新增項目,只要下載最新的 zip 檔案即可。When an SDK update is released or if you want to pick up any recent changes and additions, just download the latest zip file.

注意

若要開啟、建置和執行 Windows 範例,您必須具有 Visual Studio 和 Windows SDK。To open, build, and run Windows samples, you must have Visual Studio and the Windows SDK. 您可以取得免費的 Visual Studio CommunityYou can get a free copy of Visual Studio Community.

若要讓範例正確運作,請務必將整個封存而不只是個別的範例解壓縮。For the samples to work correctly, be sure to unzip the entire archive and not individual samples. 許多範例都取決於 SharedContent 資料夾中的常見檔案,並使用連結的檔案 (包括範例範本檔案與影像資產) 來減少重複。Many of the samples depend on common files in the SharedContent folder and use linked files, including sample template files and image assets, to reduce duplication.

開啟範例Open the samples

下載 .zip 檔案之後,請在 Visual Studio 中開啟範例。After you download the .zip file, open the samples in Visual Studio.

  1. 將封存解壓縮之前,請以滑鼠右鍵按一下該檔案,選取 [屬性] > [解除封鎖] > [套用]。Before you unzip the archive, right-click the file, select Properties > Unblock > Apply. 然後,將封存解壓縮到您電腦上的本機資料夾。Then, unzip the archive in a local folder on your computer.

    解壓縮的封存

  2. Samples 資料夾中的每個資料夾都包含 Windows 功能範例。Each folder in the Samples folder contains a Windows feature sample.

    範例資料夾

  3. 選取範例。Select a sample. 支援的語言會以特定語言的子資料夾來表示。Supported languages are indicated by a language-specific sub-folder.

    語言資料夾

  4. 選取所要使用語言的資料夾。Select the folder for the language you want to use. 在資料夾內容中,您會看到可在 Visual Studio 中開啟的 Visual Studio 解決方案 (.sln) 檔案。In the folder contents, you’ll see a Visual Studio solution (.sln) file that you can open in Visual Studio.

    VS 方案

提供意見反應、提出問題,並報告問題Give feedback, ask questions, and report issues

如果您有問題,請使用存放庫的 [Issues] 索引標籤來建立新的問題。If you have problems or questions, use the Issues tab in the repository to create a new issue.

意見反應影像