Build Your First WinUI App

A step-by-step guide to setting up your development environment for Windows UI development.

Setting Up Your Development Environment

Welcome to the exciting world of Windows UI development with WinUI! This guide will walk you through the essential steps to get your development environment ready to build your very first application.

Prerequisites: Ensure you have administrative privileges on your Windows machine, as some installations require them.

Step 1: Install Visual Studio

Visual Studio is the primary IDE for developing Windows applications. We recommend using the latest stable version.

  1. Download Visual Studio: Visit the official Visual Studio website and download the Community edition (free for individual developers, open-source projects, and academic research).
    Download Visual Studio
  2. Run the Installer: Once downloaded, execute the Visual Studio installer.
  3. Select Workloads: In the installer, under the "Workloads" tab, select the following:
    • .NET desktop development
    • Universal Windows Platform development
    These workloads include the necessary components for WinUI development.
  4. Install: Click the "Install" button and wait for the installation to complete. This may take some time depending on your internet connection and system specifications.

Step 2: Install the Windows SDK

The Windows Software Development Kit (SDK) provides the tools, libraries, and headers necessary to build Windows applications. Visual Studio often installs a suitable SDK version during the workload installation, but it's good to verify.

Tip: To check or install specific SDK versions, open Visual Studio Installer, click "Modify" on your Visual Studio installation, go to the "Individual components" tab, and search for "Windows 10 SDK" or "Windows 11 SDK". Ensure you have at least version 10.0.19041.0 or later.

Step 3: Install the WinUI 3 Project Templates

WinUI 3 templates provide pre-configured project structures to quickly start building WinUI applications.

  1. Open Visual Studio Developer Command Prompt: Search for "Developer Command Prompt for VS [Your Version]" in the Windows Start menu and run it as administrator.
  2. Install NuGet Package: Run the following command to install the WinUI 3 templates:
    dotnet new install Microsoft.WinUI.ProjectTemplates::2.7.0-prerelease.220923001
    (Note: The version number might be slightly different for the latest stable release. Refer to the official WinUI documentation for the most current version.)

Important: If you encounter issues with the command, ensure your .NET SDK is up to date and that you have run the command prompt as an administrator.

Step 4: Verify Your Installation

Let's create a simple WinUI project to confirm everything is set up correctly.

  1. Launch Visual Studio.
  2. Create a New Project: Click "Create a new project".
  3. Search for WinUI Template: In the template search bar, type "WinUI" and select "Blank App, Packaged (WinUI)".
  4. Configure Your Project: Give your project a name (e.g., "MyFirstWinUIApp") and choose a location. Click "Create".
  5. Run the Project: Once the project is created, press F5 or click the "Start" button to build and run your application. You should see a basic blank window.

Congratulations! You have successfully set up your development environment for WinUI and built your first application. You are now ready to explore the possibilities of building modern, beautiful Windows applications.

Next Steps: