Skip to content

Commit 8b9ca77

Browse files
drewbatgitCopilot
andcommitted
Rewrite progress-bar and pending-update, rename all four files
- toast-progress-bar -> notification-progress-bar: cleanup pass, remove desktop-only NOTE, XML tab, old GitHub link, add API links, Action Center -> Notification Center - toast-pending-update -> notification-pending-update: full rewrite with validated code, keep AfterActivationBehavior XML note - toast-headers -> notification-headers: rename with cross-ref updates - app-notifications-content: add data binding mentions to Text and Progress bar sections Co-authored-by: Copilot <[email protected]>
1 parent b4759f2 commit 8b9ca77

9 files changed

Lines changed: 230 additions & 312 deletions

.openpublishing.redirection.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9553,6 +9553,16 @@
95539553
{
95549554
"redirect_document_id": false
95559555
},
9556+
{
9557+
"source_path": "hub/apps/develop/notifications/app-notifications/toast-progress-bar.md",
9558+
"redirect_url": "notification-progress-bar",
9559+
"redirect_document_id": true
9560+
},
9561+
{
9562+
"source_path": "hub/apps/develop/notifications/app-notifications/toast-pending-update.md",
9563+
"redirect_url": "notification-pending-update",
9564+
"redirect_document_id": true
9565+
},
95569566
{
95579567
"source_path": "hub/apps/design/shell/tiles-and-notifications/choosing-a-notification-delivery-method.md",
95589568
"redirect_url": "../../../develop/notifications/choosing-a-notification-delivery-method",
@@ -9630,12 +9640,12 @@
96309640
},
96319641
{
96329642
"source_path": "hub/apps/design/shell/tiles-and-notifications/toast-pending-update.md",
9633-
"redirect_url": "../../../develop/notifications/app-notifications/toast-pending-update",
9643+
"redirect_url": "../../../develop/notifications/app-notifications/notification-pending-update",
96349644
"redirect_document_id": false
96359645
},
96369646
{
96379647
"source_path": "hub/apps/design/shell/tiles-and-notifications/toast-progress-bar.md",
9638-
"redirect_url": "../../../develop/notifications/app-notifications/toast-progress-bar",
9648+
"redirect_url": "../../../develop/notifications/app-notifications/notification-progress-bar",
96399649
"redirect_document_id": false
96409650
},
96419651
{

hub/apps/develop/notifications/app-notifications/app-notifications-content.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ For all attributes supported in the **visual** section and its child elements, s
8282

8383
## Text elements
8484

85-
Each app notification must have at least one text element, and can contain two additional text elements, all of type [**AdaptiveText**](notification-schema.md#adaptivetext).
85+
Each app notification must have at least one text element, and can contain two additional text elements, all of type [**AdaptiveText**](notification-schema.md#adaptivetext). Text elements support data binding, which allows you to update text content after the notification is displayed. For more information, see [App notification progress bar and data binding](notification-progress-bar.md).
8686

8787
![A screenshot of an app notification with three lines of text. The top line of text is bold.](images/toast-content-text-elements.png)
8888

@@ -296,11 +296,11 @@ var builder = new AppNotificationBuilder()
296296

297297
## Progress bar
298298

299-
You can provide a progress bar on your app notification to keep the user informed of the progress of operations such as downloads.
299+
You can provide a progress bar on your app notification to keep the user informed of the progress of operations such as downloads. Progress bars support data binding, which allows you to dynamically update the progress values after the notification is displayed.
300300

301301
![A screenshot of an app notification showing a progress bar.](images/toast-content-progress-bar.png)
302302

303-
To learn more about using a progress bar, please see [Toast progress bar](toast-progress-bar.md).
303+
To learn more about using a progress bar, see [App notification progress bar and data binding](notification-progress-bar.md).
304304

305305

306306
## Headers

hub/apps/develop/notifications/app-notifications/app-notifications-quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void MainWindow::UpdateNotificationUI(winrt::hstring const& action, winrt::hstri
422422

423423
- [App notifications overview](index.md)
424424
- [App notification content](app-notifications-content.md)
425-
- [App notification progress bar](toast-progress-bar.md)
425+
- [App notification progress bar](notification-progress-bar.md)
426426
- [Notifications code sample on GitHub](https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/Notifications/)
427427
- [Microsoft.Windows.AppNotifications API reference](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications)
428428
- [Notifications XML schema](/uwp/schemas/tiles/toastschema/schema-root)

hub/apps/develop/notifications/app-notifications/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ This section provides design and implementation guidance for app notifications i
3333
## Additional app notifications features
3434

3535
- [Custom audio on app notifications](custom-audio-on-toasts.md)
36-
- [App notification progress bar and data binding](toast-progress-bar.md)
37-
- [App notification with pending update activation](toast-pending-update.md)
36+
- [App notification progress bar and data binding](notification-progress-bar.md)
37+
- [App notification with pending update](notification-pending-update.md)
3838
- [Custom timestamps on app notifications](custom-timestamps-on-toasts.md)
3939
- [App notification collections](notification-collections.md)
4040
- [App notification headers](notification-headers.md)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
description: Learn how to use pending update activation to create multi-step interactions in your app notifications.
3+
title: App notification with pending update
4+
label: App notification with pending update
5+
template: detail.hbs
6+
ms.date: 07/28/2025
7+
ms.topic: how-to
8+
keywords: windows 11, windows app sdk, winappsdk, notification, pending update, pendingupdate, multi-step interactivity, multi-step interactions
9+
ms.localizationpriority: medium
10+
---
11+
# App notification with pending update
12+
13+
You can use **PendingUpdate** to create multi-step interactions in your app notifications. For example, you can create a series of notifications where subsequent notifications depend on responses from the previous notifications.
14+
15+
![Toast with pending update](images/toast-pendingupdate.gif)
16+
17+
For more information about app notifications, see [App notifications overview](index.md).
18+
19+
## Overview
20+
21+
To implement a notification that uses pending update as its after-activation behavior:
22+
23+
1. On your background activation buttons, specify an **afterActivationBehavior** of **pendingUpdate**.
24+
2. Assign a **Tag** (and optionally **Group**) when sending your notification.
25+
3. When the user clicks the button, your background task is activated and the notification stays on-screen in a pending update state.
26+
4. In your background task, send a new notification with new content using the same **Tag** and **Group** to replace the pending notification.
27+
28+
## Set the pending update behavior
29+
30+
> [!NOTE]
31+
> [**AppNotificationButton**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.builder.appnotificationbutton) doesn't currently support `AfterActivationBehavior`. Use the XML payload directly with the [**AppNotification**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotification) constructor to set `afterActivationBehavior="pendingUpdate"` on your buttons.
32+
33+
On your background activation buttons, set `afterActivationBehavior` to `pendingUpdate`. This only works for buttons with `activationType="background"`.
34+
35+
```csharp
36+
using Microsoft.Windows.AppNotifications;
37+
38+
string xml = @"
39+
<toast>
40+
<visual>
41+
<binding template='ToastGeneric'>
42+
<text>Would you like to order lunch today?</text>
43+
</binding>
44+
</visual>
45+
<actions>
46+
<action
47+
content='Yes'
48+
arguments='action=orderLunch'
49+
activationType='background'
50+
afterActivationBehavior='pendingUpdate'/>
51+
<action
52+
content='No'
53+
arguments='action=cancelLunch'
54+
activationType='background'/>
55+
</actions>
56+
</toast>";
57+
58+
var notification = new AppNotification(xml);
59+
notification.Tag = "lunch";
60+
61+
AppNotificationManager.Default.Show(notification);
62+
```
63+
64+
## Replace the notification with new content
65+
66+
In response to the user clicking the button, your background task is triggered and you replace the notification by sending a new notification with the same **Tag** and **Group**. We recommend muting the audio on replacements in response to a button click, since the user is already interacting with the notification.
67+
68+
```csharp
69+
var notification = new AppNotificationBuilder()
70+
.AddText("Ordering your lunch...")
71+
.MuteAudio()
72+
.BuildNotification();
73+
74+
notification.Tag = "lunch";
75+
76+
AppNotificationManager.Default.Show(notification);
77+
```
78+
79+
## See also
80+
81+
- [App notifications overview](index.md)
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
description: Use a progress bar inside your app notification to convey the status of long-running operations to the user.
3+
title: App notification progress bar and data binding
4+
label: App notification progress bar and data binding
5+
template: detail.hbs
6+
ms.date: 07/28/2025
7+
ms.topic: how-to
8+
keywords: windows 11, windows app sdk, winappsdk, progress bar, notification, data binding
9+
ms.localizationpriority: medium
10+
---
11+
# App notification progress bar and data binding
12+
13+
Using a progress bar inside your app notification allows you to convey the status of long-running operations to the user, like downloads, video rendering, exercise goals, and more.
14+
15+
A progress bar inside an app notification can either be "indeterminate" (no specific value, animated dots indicate an operation is occurring) or "determinate" (a specific percent of the bar is filled, like 60%).
16+
17+
The image below shows a determinate progress bar with all of its corresponding properties labeled.
18+
19+
For more information about app notifications, see [App notifications overview](index.md).
20+
21+
<img alt="App notification with progress bar properties labeled" src="images/toast-progressbar-annotated.png" width="626"/>
22+
23+
| Property | Type | Required | Description |
24+
|---|---|---|---|
25+
| **Title** | string or [BindableString](notification-schema.md#bindablestring) | false | Gets or sets an optional title string. Supports data binding. |
26+
| **Value** | double or [AdaptiveProgressBarValue](notification-schema.md#adaptiveprogressbarvalue) or [BindableProgressBarValue](notification-schema.md#bindableprogressbarvalue) | false | Gets or sets the value of the progress bar. Supports data binding. Defaults to 0. Can either be a double between 0.0 and 1.0, `AdaptiveProgressBarValue.Indeterminate`, or `new BindableProgressBarValue("myProgressValue")`. |
27+
| **ValueStringOverride** | string or [BindableString](notification-schema.md#bindablestring) | false | Gets or sets an optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed. |
28+
| **Status** | string or [BindableString](notification-schema.md#bindablestring) | true | Gets or sets a status string (required), which is displayed underneath the progress bar on the left. This string should reflect the status of the operation, like "Downloading..." or "Installing..." |
29+
30+
Use [**AppNotificationBuilder.AddProgressBar**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.builder.appnotificationbuilder.addprogressbar) to add a progress bar to your notification. The following example generates the notification shown above.
31+
32+
```csharp
33+
var builder = new AppNotificationBuilder()
34+
.AddText("Downloading your weekly playlist...")
35+
.AddProgressBar(new AppNotificationProgressBar()
36+
.SetTitle("Weekly playlist")
37+
.SetValue(0.6)
38+
.SetValueStringOverride("15/26 songs")
39+
.SetStatus("Downloading..."));
40+
```
41+
42+
To dynamically update the values of the progress bar, use data binding as described in the next section.
43+
44+
## Update a progress bar with data binding
45+
46+
To display a live progress bar, use data binding to update the notification values without re-sending the entire notification.
47+
48+
1. Construct notification content with data-bound fields by calling the `Bind` methods on [**AppNotificationProgressBar**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.builder.appnotificationprogressbar).
49+
2. Assign a **Tag** (and optionally a **Group**) to identify the notification.
50+
3. Set the initial [**AppNotificationProgressData**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotificationprogressdata) values.
51+
4. Show the notification by calling [**AppNotificationManager.Default.Show**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotificationmanager.show).
52+
53+
```csharp
54+
using Microsoft.Windows.AppNotifications;
55+
using Microsoft.Windows.AppNotifications.Builder;
56+
57+
string tag = "weekly-playlist";
58+
string group = "downloads";
59+
60+
var builder = new AppNotificationBuilder()
61+
.AddText("Downloading your weekly playlist...")
62+
.AddProgressBar(new AppNotificationProgressBar()
63+
.BindTitle()
64+
.BindValue()
65+
.BindValueStringOverride()
66+
.BindStatus());
67+
68+
var notification = builder.BuildNotification();
69+
notification.Tag = tag;
70+
notification.Group = group;
71+
72+
notification.Progress = new AppNotificationProgressData(1)
73+
{
74+
Title = "Weekly playlist",
75+
Value = 0.6,
76+
ValueStringOverride = "15/26 songs",
77+
Status = "Downloading..."
78+
};
79+
80+
AppNotificationManager.Default.Show(notification);
81+
```
82+
83+
Then, update the progress values by calling [**AppNotificationManager.Default.UpdateAsync**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotificationmanager.updateasync) with a new [**AppNotificationProgressData**](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotificationprogressdata) instance. Increment the sequence number so the platform knows this is a newer update.
84+
85+
```csharp
86+
using Microsoft.Windows.AppNotifications;
87+
88+
string tag = "weekly-playlist";
89+
string group = "downloads";
90+
91+
var data = new AppNotificationProgressData(2)
92+
{
93+
Value = 0.7,
94+
ValueStringOverride = "18/26 songs"
95+
};
96+
97+
await AppNotificationManager.Default.UpdateAsync(data, tag, group);
98+
```
99+
100+
Using **UpdateAsync** rather than replacing the entire notification ensures that the notification stays in the same position in Notification Center and doesn't move up or down. The method returns a [**NotificationUpdateResult**](/uwp/api/windows.ui.notifications.notificationupdateresult) that indicates whether the update succeeded or whether the notification couldn't be found (the user may have dismissed it).
101+
102+
## Elements that support data binding
103+
104+
The following elements in app notifications support data binding:
105+
106+
- All properties on **AppNotificationProgressBar**
107+
- The **Text** property on the top-level text elements
108+
109+
## Update or replace a notification
110+
111+
You can **replace** a notification by sending a new notification with the same **Tag** and **Group**. The following table describes the difference between replacing and updating a notification.
112+
113+
| | Replacing | Updating |
114+
| -- | -- | -- |
115+
| **Position in Notification Center** | Moves the notification to the top of Notification Center. | Leaves the notification in place within Notification Center. |
116+
| **Modifying content** | Can completely change all content and layout of the notification. | Can only change properties that support data binding (progress bar and top-level text). |
117+
| **Reappearing as popup** | Can reappear as a popup if **SuppressPopup** is `false` (or set to `true` to silently send it to Notification Center). | Won't reappear as a popup; the notification's data is silently updated within Notification Center. |
118+
| **User dismissed** | Replacement notification is always sent regardless of whether the user dismissed the previous notification. | If the user dismissed the notification, the update will fail. |
119+
120+
In general, **updating** is useful for information that changes frequently and doesn't require the user's immediate attention, such as progress changing from 50% to 65%.
121+
122+
After your sequence of updates has completed (for example, a file has finished downloading), consider **replacing** the notification for the final step because:
123+
124+
- The final notification likely has different layout, such as removal of the progress bar or addition of new buttons.
125+
- The user may have dismissed the progress notification but still wants to see a popup when the operation completes.
126+
127+
## See also
128+
129+
- [App notifications overview](index.md)

0 commit comments

Comments
 (0)