AppNotificationProgressBar Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a progress bar that is displayed on an app notification.
public ref class AppNotificationProgressBar sealed
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class AppNotificationProgressBar final
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class AppNotificationProgressBar
function AppNotificationProgressBar()
Public NotInheritable Class AppNotificationProgressBar
- Inheritance
- Attributes
Examples
The following example demonstrates adding a progress bar to the XML payload for an app notification.
var notification = new AppNotificationBuilder()
.AddText("Downloading your weekly playlist...")
.AddProgressBar(new AppNotificationProgressBar()
.BindTitle()
.BindStatus()
.BindValue()
.BindValueStringOverride())
.SetTag(tagName)
.SetGroup(groupName))
.BuildNotification();
var data = new AppNotificationProgressData (sequenceNumber /* Sequence number */);
data.Title = "Retreiving files"; // Binds to {progressTitle} in xml payload
data.Value = (double) currentFile / totalFiles; // Binds to {progressValue} in xml payload
data.ValueStringOverride = String.Format("{0}/{1} files", currentFile, totalFiles); // Binds to {progressValueString} in xml payload
data.Status = "Downloading..."; // Binds to {progressStatus} in xml payload
notification.Progress = data;
AppNotificationManager.Default.Show(notification);
The resulting XML payload:
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Downloading your weekly playlist...</text>
<progress title='{progressTitle}' status='{progressStatus}' value='{progressValue}' valueStringOverride='{progressValueString}'/>
</binding>
</visual>
</toast>
Update the bound values by calling AppNotificationManager.UpdateAsync) and specifying the tag, and optionally the group, of the tag you want to update.
private async Task UpdateProgressBar()
{
var data = new AppNotificationProgressData(sequenceNumber /* Sequence number */);
data.Title = "Retreiving files"; // Binds to {progressTitle} in xml payload
data.Value = (double)currentFile / totalFiles; // Binds to {progressValue} in xml payload
data.ValueStringOverride = String.Format("{0}/{1} files", currentFile, totalFiles); // Binds to {progressValueString} in xml payload
data.Status = (currentFile < totalFiles) ? "Downloading..." : "Complete!"; // Binds to {progressStatus} in xml payload
await AppNotificationManager.Default.UpdateAsync(data, tagName, groupName);
}
Remarks
The following screenshot shows an app notification with a progress bar.
Add a progress bar to the XML payload for an app notification by calling AppNotificationBuilder.AddProgressBar).
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.
Constructors
AppNotificationProgressBar() |
Initializes a new instance of the AppNotificationProgressBar class. |
Properties
Status |
Gets or sets the status text of an app notification progress bar. |
Title |
Gets or sets a the title text of an app notification progress bar. |
Value |
Gets or sets the progress value of an app notification progress bar. |
ValueStringOverride |
Gets or sets the value string override of an app notification progress bar. |
Methods
BindStatus() |
Binds the AppNotificationProgressBar.Status property. |
BindTitle() |
Binds the AppNotificationProgressBar.Title property. |
BindValue() |
Binds the AppNotificationProgressBar.Value property. |
BindValueStringOverride() |
Binds the AppNotificationProgressBar.ValueStringOverride property. |
SetStatus(String) |
Sets the status text of an app notification progress bar. |
SetTitle(String) |
Sets the title text of an app notification progress bar. |
SetValue(Double) |
Sets the progress value of an app notification progress bar. |
SetValueStringOverride(String) |
Sets the value string override of an app notification progress bar. |