Getting Started with WinUI
Welcome to WinUI, the modern UI platform for Windows. This guide will walk you through the initial steps to start building beautiful and performant Windows applications with WinUI 3.
Tip: WinUI 3 is the latest native UI platform for Windows, offering a rich set of controls and modern APIs for building Windows applications. It's the evolution of the Universal Windows Platform (UWP) and the Fluent Design System.
Prerequisites
Before you begin, ensure you have the following installed:
- Visual Studio: We recommend Visual Studio 2022 (version 17.0 or later).
- Windows 10 SDK: Version 19041 (Windows 10, version 2004) or later.
- .NET 6.0 Desktop Runtime: Or a later version of the .NET SDK.
You can install Visual Studio and the necessary SDKs from the Visual Studio website.
Step 1: Install the WinUI 3 Project Templates
Open Visual Studio Installer. Select "Modify" for your Visual Studio installation. Under "Individual components", search for "WinUI" and ensure "Windows App SDK C# templates" is checked. If you don't see it, you may need to install the latest Visual Studio preview or check for updates.
Note: The WinUI 3 project templates are bundled with the Windows App SDK. Make sure you have the latest version of the Windows App SDK installed via NuGet or through the Visual Studio Installer.
Step 2: Create Your First WinUI 3 Application
Now that you have the templates installed, let's create a new project:
- In Visual Studio, go to File > New > Project...
- Search for "WinUI" and select the Blank App, Packaged (WinUI 3 in Desktop) template.
- Click Next.
- Give your project a name (e.g., "MyFirstWinUIApp") and choose a location.
- Click Create.

Step 3: Run Your Application
After the project is created, you should see a basic WinUI application structure. To run it:
- Ensure the target is set to Windows PC in the Visual Studio toolbar.
- Click the Start Debugging button (or press F5).
A simple window will appear, showcasing the default WinUI application frame. This is your starting point!
Step 4: Understanding the Project Structure
Your new WinUI project will have a few key files:
- App.xaml and App.xaml.cs: These define the application's entry point and global resources.
- MainWindow.xaml and MainWindow.xaml.cs: These define the main window of your application, including its layout and logic.
- Assets folder: Contains application icons and other visual assets.
Let's look at a simplified example of MainWindow.xaml
:
<Window x:Class="MyFirstWinUIApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyFirstWinUIApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="Hello, WinUI!" FontSize="32"/>
</StackPanel>
</Window>
And the corresponding MainWindow.xaml.cs
:
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
namespace MyFirstWinUIApp
{
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
}
}
}
Next Steps
Congratulations! You've successfully set up your development environment and created your first WinUI application. Now you can explore:
- Adding more UI controls to your windows.
- Handling user input and events.
- Styling your application with XAML and the Fluent Design System.
- Learning about data binding and MVVM.
Continue to the Tutorials section to build more complex features.
Important: WinUI 3 is continuously updated. Always ensure you are using the latest stable versions of Visual Studio and the Windows App SDK for the best experience and latest features.