WinUI Documentation

Getting Started

Welcome to the WinUI documentation. WinUI is the modern native UI platform for Windows apps. Follow the steps below to create your first WinUI project.

  1. Install the Windows App SDK using the Visual Studio Installer.
  2. Create a new project and select WinUI App (Project Reunion).
  3. Run the project to see a blank window powered by WinUI.
dotnet new winui -n MyFirstWinUIApp
cd MyFirstWinUIApp
dotnet run

Common Controls

WinUI provides a rich set of controls. Below are examples of the most used ones.

Button

<Button Content="Click me" Click="OnClick"/>

TextBox

<TextBox PlaceholderText="Enter text..." Width="200"/>

ListView

<ListView ItemsSource="{x:Bind Items}" Height="200"/>

Layouts

Arrange UI elements using versatile layout panels.

StackPanel

<StackPanel Orientation="Vertical">
    <TextBlock Text="Item 1"/>
    <TextBlock Text="Item 2"/>
</StackPanel>

Grid

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <TextBlock Grid.Row="0" Text="Header"/>
    <ListView Grid.Row="1"/>
</Grid>

Styling and Theming

Customize the look of your app using ResourceDictionary and theme resources.

<Page.Resources>
    <SolidColorBrush x:Key="PrimaryBrush" Color="#0078D4"/>
    <Style TargetType="Button">
        <Setter Property="Background" Value="{StaticResource PrimaryBrush}"/>
        <Setter Property="Foreground" Value="White"/>
    </Style>
</Page.Resources>

Advanced Topics

Explore advanced capabilities such as custom controls, data binding, and performance optimization.

Custom Control

public sealed class MyControl : Control
{
    public MyControl()
    {
        this.DefaultStyleKey = typeof(MyControl);
    }
}

Data Binding

<TextBlock Text="{Binding Path=UserName, Mode=OneWay}" />