-api-id | -api-type |
---|---|
M:Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.AddProgressBar(Microsoft.Windows.AppNotifications.Builder.AppNotificationProgressBar) |
winrt method |
Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.AddProgressBar(Microsoft.Windows.AppNotifications.Builder.AppNotificationProgressBar)
Adds a progress bar to the XML payload for an app notification.
An AppNotificationProgressBar representing the progress bar to be added to the notification.
Returns the AppNotificationBuilder instance so that additional method calls can be chained.
Bind the fields of an AppNotificationProgressData to set the initial values and updated status of the progress bar. For information on data binding to a progress bar in an app notification, see App notification progress bar and data binding.
For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.
For reference information about the XML schema for app notifications, see App notification content schema.
The following example demonstrates adding a combo box to an app notification.
var builder = new AppNotificationBuilder()
.AddText("Downloading this week's new music...")
.AddProgressBar(new AppNotificationProgressBar()
.BindTitle()
.BindValueStringOverride());
var data = new AppNotificationProgressData(1 /* Sequence number */);
data.Title = "Artist Name"; // Binds to {progressTitle} in xml payload
data.Value = 0.5; // Binds to {progressValue} in xml payload
data.ValueStringOverride = "1/2 songs"; // Binds to {progressValueString} in xml payload
data.Status = "Downloading..."; // Binds to {progressStatus} in xml payload
var notification = builder.BuildNotification();
notification.Progress = data;
AppNotificationManager.Default.Show(notification);
The resulting XML payload:
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Downloading this week's new music...</text>
<progress title='{progressTitle}' status='{progressStatus}' value='{progressValue}' valueStringOverride='{progressValueString}'/>
</binding>
</visual>
</toast>