Skip to content

Commit eb0e5fd

Browse files
authored
add WinUI Notes tutorial (#5172)
* add WinUI Notes tutorial * fix build warnings * edits * Add step to remove template sample code * updated to use TitleBar control * simplify TextBox XAML * updates, rewrites, new images * add info about Task * fix formatting * add links to GitHub repo * few small edits
1 parent c58c2c5 commit eb0e5fd

25 files changed

+1383
-5
lines changed

hub/apps/get-started/start-here.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Get started with Windows development using WinUI
33
description: List of steps to get started developing Windows apps with WinUI and the Windows App SDK.
44
ms.topic: how-to
5-
ms.date: 08/19/2024
5+
ms.date: 03/24/2025
66
keywords: windows, desktop development
77
ms.localizationpriority: medium
88
ms.collection: windows11
@@ -72,7 +72,6 @@ On the **Workloads** tab of the Visual Studio Installer app, select the followin
7272

7373
---
7474

75-
7675
## 3. Create and launch your first WinUI app
7776

7877
Visual Studio project templates include all the files you need to quickly create your app. In fact, after you create your project from a WinUI app template, you'll already have an app that you can run, and then add your code to.
@@ -87,14 +86,56 @@ To create a new project using the WinUI C# Blank App project template:
8786

8887
1. Specify a project name, then click **Create**. You can optionally specify a solution name and directory, or leave the defaults. In this image, the `Hello World` project belongs to a `Hello World` solution, which will live in `C:\Projects\`:
8988
:::image type="content" source="images/hello-world/configure-project.png" alt-text="Specify project details":::
89+
90+
> [!NOTE]
91+
> If you want to use this project to build the complete app in the Next steps section, name the project `WinUINotes`.
92+
9093
1. Click the Debug "Start" button to build and run your project:<br/>
9194
:::image type="content" source="images/hello-world/start-click.png" alt-text="Build and run your project":::<br/>
92-
Your `Hello World` project will build, be deployed to your local machine, and run in debug mode:<br/>
95+
Your project will build, be deployed to your local machine, and run in debug mode:<br/>
9396
:::image type="content" source="images/hello-world/click-me.png" alt-text="Hello World project built and running":::
9497

9598
1. To stop debugging, close the app window, or click the debug "Stop" button in Visual Studio.
9699

97-
## 4. Update to the latest WinUI/Windows App SDK
100+
## 4. Delete sample code
101+
102+
The `MainWindow` class included with the project template includes some sample code that needs to be removed to make room for your content.
103+
104+
1. Double-click `MainWindow.xaml` in **Solution Explorer** to open it. You should see XAML markup for a `StackPanel` control.
105+
1. Delete the XAML for the `StackPanel`. (You'll add your own content in it's place as you create your app.)
106+
107+
```xaml
108+
<!-- ↓ Delete this. ↓ -->
109+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
110+
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
111+
</StackPanel>
112+
```
113+
114+
If you try to run your app now, Visual Studio will throw an error along the lines of `The name 'myButton' does not exist in the current context`. This is because you deleted the `Button` control named `myButton`, but it's still referenced in the `MainPage.xaml.cs` code-behind file. Delete the reference in the code file, too.
115+
116+
1. Double-click `MainWindow.xaml.cs` in **Solution Explorer** to open it.
117+
1. Delete the `myButton_Click` event handler.
118+
119+
```csharp
120+
public sealed partial class MainWindow : Window
121+
{
122+
public MainWindow()
123+
{
124+
this.InitializeComponent();
125+
}
126+
127+
// ↓ Delete this. ↓
128+
private void myButton_Click(object sender, RoutedEventArgs e)
129+
{
130+
myButton.Content = "Clicked";
131+
}
132+
// End delete.
133+
}
134+
```
135+
136+
1. Save the file by pressing <kbd>CTRL + SHIFT + S</kbd>, clicking the Save All icon in the tool bar, or by selecting the menu **File** > **Save All**.
137+
138+
## 5. Update to the latest WinUI/Windows App SDK
98139

99140
The Windows App SDK (and WinUI, which is part of it) is distributed as a [NuGet](/nuget/what-is-nuget) package. This means updates can be released out-of-sync with Windows and Visual Studio. As a result, the Visual Studio template you used to create your project might not reference the latest Windows App SDK NuGet package. To ensure you have the latest features and fixes, you should update your NuGet packages every time you create a new project in Visual Studio.
100141

@@ -110,7 +151,9 @@ Now your project is using the latest WinUI features that are available, and it's
110151

111152
## Next steps
112153

113-
* Complete a tutorial to [add more code to your Hello World app](../how-tos/hello-world-winui3.md).
154+
> [!div class="nextstepaction"]
155+
> [Complete a tutorial to create a note app with WinUI](../tutorials/winui-notes/index.yml)
156+
114157
* To get an idea of what WinUI has to offer, check out the WinUI Gallery app.
115158
[!INCLUDE [winui-3-gallery](../../includes/winui-3-gallery.md)]
116159
* Learn more about [WinUI fundamentals](../develop/index.md).

0 commit comments

Comments
 (0)