Skip to content

Commit 22496e5

Browse files
Merge pull request #6491 from MicrosoftDocs/main
Auto Publish – main to live - 2026-03-19 23:06 UTC
2 parents f8a173c + 7e28044 commit 22496e5

11 files changed

Lines changed: 358 additions & 28 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Windows notifications overview
3+
description: Understand which Windows notification API to use for your app type—AppNotificationManager (Windows App SDK) vs ToastNotificationManager (WinRT/UWP)—and choose the right delivery method.
4+
ms.topic: overview
5+
ms.date: 03/19/2026
6+
keywords: toast, notification, AppNotificationManager, ToastNotificationManager, WNS, push notification, Windows App SDK
7+
ms.localizationpriority: medium
8+
---
9+
10+
# Windows notifications overview
11+
12+
Windows provides several notification APIs across different SDK generations. If you're searching online for how to send a notification and finding conflicting examples, this page will help you pick the right API for your app.
13+
14+
## Which API should I use?
15+
16+
The answer depends on which SDK your app targets:
17+
18+
| App type | Recommended API | Namespace |
19+
|---|---|---|
20+
| WinUI 3 / Windows App SDK (new apps) | `AppNotificationManager` | `Microsoft.Windows.AppNotifications` |
21+
| WPF, WinForms, or unpackaged Win32 | `AppNotificationManager` via NuGet | `Microsoft.Windows.AppNotifications` |
22+
| UWP (existing apps, no migration planned) | `ToastNotificationManager` | `Windows.UI.Notifications` |
23+
24+
> [!IMPORTANT]
25+
> Most Stack Overflow answers and older tutorials use `ToastNotificationManager` from the `Windows.UI.Notifications` namespace. This is the **UWP WinRT API**. It works in UWP apps and may work in some desktop scenarios, but it is not the recommended path for new Windows App SDK apps. Use `AppNotificationManager` for new development.
26+
27+
## Notifications API comparison
28+
29+
| Feature | `AppNotificationManager` (Windows App SDK) | `ToastNotificationManager` (WinRT) |
30+
|---|---|---|
31+
| **Recommended for** | WinUI 3, WPF, WinForms, unpackaged Win32 | UWP |
32+
| **NuGet package** | `Microsoft.WindowsAppSDK` | None (inbox) |
33+
| **Package identity required** | No (works packaged and unpackaged) | Required for some features |
34+
| **Push integration** | `PushNotificationManager` (Windows App SDK) | WNS channel APIs (`Windows.Networking.PushNotifications`) |
35+
| **Active development** | Yes | Maintenance only |
36+
37+
## Types of notifications
38+
39+
Once you've chosen the right API, decide how your notification will be delivered:
40+
41+
| Type | Description | Use when |
42+
|---|---|---|
43+
| **Local app notification** | Triggered directly by your app code while running | You want to alert the user of an in-app event |
44+
| **Scheduled** | Set a future time for the notification to appear | Calendar reminders, alarms |
45+
| **Push (WNS)** | Sent from your cloud service via Windows Push Notification Services | Chat messages, breaking news, real-time updates |
46+
| **Badge** | Small overlay on the app's taskbar icon | Unread count, status indicator |
47+
48+
For a full breakdown of delivery methods, see [Choose a notification delivery method](choosing-a-notification-delivery-method.md).
49+
50+
## Next steps
51+
52+
**Building a WinUI 3 or Windows App SDK app?**
53+
- [App notifications overview](app-notifications/index.md) — local and push app notifications using `AppNotificationManager`
54+
- [App notifications quickstart](app-notifications/app-notifications-quickstart.md)
55+
- [Push notifications overview](push-notifications/index.md) — WNS push using `PushNotificationManager`
56+
57+
**Building or maintaining a UWP app?**
58+
- [Send a local app notification from C++ UWP apps](app-notifications/send-local-toast-cpp-uwp.md)
59+
- [Windows Push Notification Services (WNS) overview](push-notifications/wns-overview.md)
60+
61+
**Migrating a UWP app to Windows App SDK?**
62+
- [Migrate toast notifications](../../windows-app-sdk/migrate-to-windows-app-sdk/guides/toast-notifications.md)
63+
- [Migrate push notifications](../../windows-app-sdk/migrate-to-windows-app-sdk/guides/notifications.md)

hub/apps/develop/toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ items:
412412
- name: Visual feedback
413413
href: input/guidelines-for-visualfeedback.md
414414
- name: Notifications
415+
href: notifications/index.md
415416
items:
416417
- name: Push notifications
417418
items:

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ In the Visual Studio Installer, select the following workloads on the **Workload
5858

5959
* **For C++ app development**, select the **C++ WinUI app development tools** under the **WinUI application development** node in the **Installation details** pane (This will also select any additional required components.)
6060

61+
> [!TIP]
62+
> If you don't see WinUI templates after installing Visual Studio, open the Visual Studio Installer, select **Modify**, and confirm the **WinUI application development** workload is checked. Restart Visual Studio after modifying the installation.
63+
6164
---
6265

6366
## Create and launch your first WinUI app
@@ -66,6 +69,9 @@ In the Visual Studio Installer, select the following workloads on the **Workload
6669

6770
2. Search for **WinUI**, select the **WinUI Blank App (Packaged)** C# project template, and select **Next**.
6871

72+
> [!NOTE]
73+
> The **Packaged** template is recommended for new apps. A packaged app (using MSIX) gives your users a clean install and uninstall experience, and enables Windows features like notifications, background tasks, and the Microsoft Store. You can learn more about the packaged vs. unpackaged choice in [Windows apps: packaging, deployment, and process](intro-pack-dep-proc.md).
74+
6975
:::image type="content" source="images/hello-world/create-project.png" lightbox="images/hello-world/create-project.png" alt-text="Blank, packaged WinUI C# desktop app":::
7076

7177
3. Enter a project name and select **Create**.

hub/apps/get-started/windows-developer-faq.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ Topics covered include:
103103
104104
</details>
105105

106+
<details><summary>I get an "Unable to load DLL 'Microsoft.ui.xaml.dll'" error when running my app. How do I fix it?</summary>
107+
108+
> This error usually occurs in **unpackaged** app scenarios where the Windows App SDK runtime hasn't been installed on the machine. Try the following:
109+
>
110+
> - If you're running a **packaged** app (the recommended default), ensure you're launching via Visual Studio with the **MsixPackage** launch profile selected (not the plain executable profile). The MSIX packaging step installs the required runtime components.
111+
> - If you're running an **unpackaged** app, you must install the [Windows App SDK runtime](../windows-app-sdk/downloads.md) separately before running the app outside of Visual Studio.
112+
> - If the error occurs during development, open your `.csproj` and confirm that your packaging configuration matches your deployment model: for **packaged** apps, omit the `<WindowsPackageType>` property (or leave it at its default) and build/run the MSIX package; for **unpackaged** apps, set `<WindowsPackageType>None</WindowsPackageType>` and ensure you've called `Bootstrap.Initialize()` at startup.
113+
>
114+
> See [Deploy apps that use the Windows App SDK](../package-and-deploy/deploy-overview.md) for more details on deployment requirements.
115+
116+
</details>
117+
106118
<details><summary>What is the difference between WinUI and WinUI for UWP?</summary>
107119

108120
> **WinUI** (previously referred to as WinUI 3) is the latest native UI framework for Windows app development. It provides a modern and flexible UI framework for creating visually appealing and interactive Windows apps. WinUI is part of the Windows App SDK and works best with the latest versions of Windows.

hub/apps/how-tos/github-copilot-winui-vs.md

Lines changed: 89 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: How to use GitHub Copilot to create WinUI apps in Visual Studio
3-
description: Get started with WinUI / Windows App SDK by using the GitHub Copilot code completion capabilities in Visual Studio.
3+
description: Get started with WinUI / Windows App SDK by using the GitHub Copilot code completion and chat capabilities in Visual Studio.
44
ms.topic: how-to
5-
ms.date: 10/28/2025
5+
ms.date: 03/19/2026
66
keywords: windows app sdk, winappsdk, winui, copilot, github copilot
77
ms.localizationpriority: medium
88
audience: new-desktop-app-developers
@@ -11,14 +11,14 @@ audience: new-desktop-app-developers
1111

1212
# Use GitHub Copilot to create WinUI 3 / Windows App SDK apps in Visual Studio
1313

14-
In this how-to, we'll demonstrate how [GitHub Copilot](https://github.com/features/copilot) can be used to build WinUI / Windows App SDK desktop apps in Visual Studio. This guide builds upon *[What is GitHub Copilot Completions for Visual Studio?](/visualstudio/ide/visual-studio-github-copilot-extension)*, offering tailored tips and best practices for Copilot-assisted WinUI app development.
14+
In this how-to, we'll demonstrate how [GitHub Copilot](https://github.com/features/copilot) can be used to build WinUI / Windows App SDK desktop apps in Visual Studio. This guide builds upon *[GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-extension)*, offering tailored tips and best practices for Copilot-assisted WinUI app development.
1515

1616
:::image type="content" source="images/github-copilot-winui-vs/github-copilot-extension-example.gif" alt-text="Animated screenshot that shows the code completion capabilities of the GitHub Copilot in Visual Studio.":::
1717

1818
## Prerequisites
1919

20-
- Visual Studio 2022 (v17.10+) with the **WinUI application development** workload applied (see [Get started with WinUI](../get-started/start-here.md) for additional configuration details). GitHub Copilot is included in Visual Studio 2022 v17.10 and later by default.
21-
- An active subscription to [GitHub Copilot](https://github.com/features/copilot/plans) associated with the GitHub account that you sign in to Visual Studio with.
20+
- Visual Studio 2022 (v17.10 or later) or Visual Studio 2026, with the **WinUI application development** workload applied (see [Set up your environment and create your first WinUI project](../get-started/start-here.md) for setup details). GitHub Copilot is included in Visual Studio 2022 v17.10 and later by default.
21+
- A GitHub account with access to [GitHub Copilot](https://github.com/features/copilot/plans). GitHub Copilot is available for free for individual developers; paid plans are also available. Sign in to Visual Studio with the same GitHub account.
2222
- Familiarity with C#, WinUI, and Windows App SDK.
2323

2424
## Use GitHub Copilot
@@ -34,46 +34,115 @@ GitHub Copilot in Visual Studio provides real-time code suggestions and completi
3434
> [!TIP]
3535
> If you don't see the GitHub Copilot suggestions, you can enable different aspects of the feature in Visual Studio's options under `Tools` -> `Options` -> `GitHub` -> `Copilot`.
3636
37-
### Ask Copilot for suggestions
37+
### Use Copilot Chat for WinUI questions
3838

39-
Right-click in the code editor and select `Ask Copilot`. A prompt window will open where you can chat inline with Copilot to get a list of suggestions based on the current cursor position and your prompt:
39+
The **Copilot Chat** panel (View > GitHub Copilot Chat) is the most flexible way to get WinUI-specific help. Unlike inline completions, Chat lets you ask multi-step questions, reference specific files, and get explanations with full context.
4040

41-
:::image type="content" source="images/github-copilot-winui-vs/2-generate-multiple-suggestions.png" alt-text="Screenshot that shows the inline prompting capabilities of GitHub Copilot.":::
41+
Open the Chat panel and try prompts like:
42+
43+
- *"Using WinUI 3 and Windows App SDK, add a NavigationView with three pages to my MainWindow"*
44+
- *"Explain how XamlRoot works in WinUI 3 and show me how to set it on a ContentDialog"*
45+
- *"Convert this event handler to use DispatcherQueue instead of CoreDispatcher"*
46+
47+
To reference a specific file in Chat, type `#` and select the file from the picker. This is particularly useful when you want Copilot to generate C# code that matches your existing XAML:
48+
49+
```
50+
#MainWindow.xaml Add click handlers in code-behind for all the buttons in this file
51+
```
52+
53+
> [!TIP]
54+
> Always include **WinUI 3** and **Windows App SDK** in your Chat prompts. Without this context, Copilot may suggest UWP patterns (such as `Window.Current` or `CoreDispatcher`) that don't work in WinUI 3. See [WinUI 3 patterns to watch for](#winui-3-patterns-to-watch-for) below.
55+
56+
### Ask Copilot for inline suggestions
57+
58+
Right-click in the code editor and select **Chat** to open an inline chat window at your cursor position. Type your question and press **Enter**:
59+
60+
:::image type="content" source="images/github-copilot-winui-vs/2-generate-multiple-suggestions.png" alt-text="Screenshot that shows the inline chat capabilities of GitHub Copilot.":::
61+
62+
> [!TIP]
63+
> You can promote an inline chat thread to the full Chat panel at any time by selecting **Copilot Actions** > **Add to Chat**. This preserves the conversation context so you can continue in the panel.
4264
4365
### Prompt Copilot with plain-language comments
4466

4567
Although Copilot is used primarily for code completion, you can also use natural language comments to guide Copilot in generating specific code snippets. For example, you can use comments to request a specific feature or functionality:
4668

4769
:::image type="content" source="images/github-copilot-winui-vs/3-prompt-copilot-with-inline-comment.png" alt-text="Screenshot that shows the code completion capabilities of GitHub Copilot (prompting).":::
4870

49-
### Use temporary comments to add code from other files to Copilot's context
71+
### Use Copilot Chat to add context from other files
5072

51-
If you're working on a code-behind file and want Copilot to incorporate context from the associated XAML file, you can use temporary comments to include this additional code within Copilot's context. Here's an example of how you can specify the XAML code first, and then have Copilot generate the corresponding C# code:
73+
If you're working on a code-behind file and want Copilot to incorporate context from the associated XAML file, reference it directly in the Chat panel using `#`:
74+
75+
```
76+
#MainPage.xaml Generate the C# event handlers for all interactive controls in this file
77+
```
78+
79+
Alternatively, for inline completions you can use temporary comments to paste the relevant XAML into the code-behind file. Copilot will use this as context when generating C# code, and you can delete the comments afterward:
5280

5381
:::image type="content" source="images/github-copilot-winui-vs/4-add-context-temporary-comments.png" alt-text="Screenshot that shows the code completion capabilities of GitHub Copilot (context expansion).":::
5482

55-
### Ask Copilot to explain how something works with inline comments
83+
### Ask Copilot to explain how something works
5684

57-
You can use inline comments to ask Copilot to explain how a specific piece of code works. This is similar to using the inline Ask Copilot feature or the Copilot Chat window, except your prompt is typed directly into the code editor:
85+
The best way to ask Copilot to explain code is to select it in the editor, then right-click and choose **Copilot Actions** > **Explain**. This opens the Chat panel with your selected code already attached as context, and Copilot provides a detailed explanation.
5886

59-
:::image type="content" source="images/github-copilot-winui-vs/5-ask-copilot-inline-explanation.png" alt-text="Screenshot that shows the code completion capabilities of GitHub Copilot (explain).":::
87+
You can also ask for explanations directly in the Chat panel using the `/explain` slash command:
6088

61-
### Use Copilot to test code standards
89+
```
90+
/explain What does this DispatcherQueue.TryEnqueue call do?
91+
```
6292

63-
You can use Copilot to generate code that adheres to your project's coding standards, and to test any given snippet's adherence to those standards. Here's an example of how you can use inline comments to specify two conventions, and then have Copilot validate the code snippet against these conventions:
93+
> [!TIP]
94+
> Slash commands like `/explain`, `/fix`, and `/doc` are shortcuts in the Chat panel that tell Copilot exactly what kind of help you want. Type `/` in the Chat input to see all available commands.
6495
65-
:::image type="content" source="images/github-copilot-winui-vs/6-enforce-code-standards.png" alt-text="Screenshot that shows the code completion capabilities of GitHub Copilot (standards).":::
96+
### Use Copilot to enforce code standards
97+
98+
The most reliable way to have Copilot follow your project's coding conventions is to add a `.github/copilot-instructions.md` file to your repository. Copilot reads this file automatically and applies the instructions to all suggestions in that repo. For example:
99+
100+
```markdown
101+
# Copilot instructions
102+
103+
- Use DispatcherQueue.TryEnqueue for all UI thread dispatch, never CoreDispatcher
104+
- Always set XamlRoot when showing a ContentDialog
105+
- Use the MVVM pattern with CommunityToolkit.Mvvm ObservableObject and RelayCommand
106+
- Target net10.0-windows10.0.19041.0 — do not use plain net10.0
107+
```
108+
109+
You can also ask Copilot to review a code snippet against specific standards in the Chat panel:
110+
111+
```
112+
Does this code follow the MVVM pattern correctly for a WinUI 3 app?
113+
```
114+
115+
> [!TIP]
116+
> For team-wide consistency, commit `.github/copilot-instructions.md` to source control. Every developer on the team will get the same Copilot behavior without any per-machine configuration.
117+
118+
## WinUI 3 patterns to watch for
119+
120+
Copilot is trained on a large body of Windows code that includes older UWP and WinUI 2 samples. When working in a WinUI 3 project, watch for these suggestions and use the correct WinUI 3 equivalents instead:
121+
122+
| Copilot may suggest | WinUI 3 equivalent | Notes |
123+
|---|---|---|
124+
| `Window.Current` | `App.MainWindow` or store a reference to your window | `Window.Current` is UWP only — it's always null in WinUI 3 |
125+
| `CoreDispatcher` / `Dispatcher.RunAsync` | `DispatcherQueue.TryEnqueue` | WinUI 3 uses `DispatcherQueue` for UI thread dispatch |
126+
| `Windows.UI.Xaml.*` namespaces | `Microsoft.UI.Xaml.*` | All WinUI 3 types are in the `Microsoft.UI.Xaml` namespace |
127+
| `MessageDialog` (Windows.UI.Popups) | `ContentDialog` with `XamlRoot` set | Set `dialog.XamlRoot = this.Content.XamlRoot` before calling `ShowAsync` |
128+
| `FileOpenPicker` without HWND | Initialize with `WinRT.Interop.InitializeWithWindow.Initialize(picker, hwnd)` | WinUI 3 pickers require an HWND; use `WinRT.Interop` to get it |
129+
| `net8.0` or `net10.0` TFM | `net10.0-windows10.0.19041.0` | The unqualified TFM excludes Windows Runtime APIs |
130+
131+
> [!TIP]
132+
> If Copilot generates a pattern from this list, paste it into the Chat panel and ask: *"Is this correct for WinUI 3 with Windows App SDK, or is this a UWP pattern?"* Copilot will usually identify and correct the issue when asked directly.
66133
67134
## Recap
68135

69136
In this how-to, we demonstrated how to use GitHub Copilot in Visual Studio to assist you with WinUI / Windows App SDK desktop app development. We covered how to:
70137

71138
- Autocomplete your code snippets.
72-
- Generate autocomplete suggestions inline with Ask Copilot.
139+
- Use the Copilot Chat panel for multi-step WinUI questions and file references.
140+
- Generate inline suggestions using right-click > **Chat**.
73141
- Prompt Copilot with plain-language comments.
74-
- Use temporary comments to add code from other files to Copilot's context.
75-
- Ask Copilot to explain how something works with inline comments.
76-
- Use Copilot to test and enforce code standards.
142+
- Use `#file` references or temporary comments to add context from other files.
143+
- Ask Copilot to explain code using **Copilot Actions** > **Explain** or the `/explain` slash command in Chat.
144+
- Use Copilot to enforce code standards with `.github/copilot-instructions.md` or Chat review.
145+
- Identify and correct UWP patterns that Copilot may suggest in WinUI 3 projects.
77146

78147
## Related content
79148

Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)