Share via


AppNotificationBuilder.AddProgressBar(AppNotificationProgressBar) Method

Definition

Adds a progress bar to the XML payload for an app notification.

public:
 virtual AppNotificationBuilder ^ AddProgressBar(AppNotificationProgressBar ^ value) = AddProgressBar;
AppNotificationBuilder AddProgressBar(AppNotificationProgressBar const& value);
public AppNotificationBuilder AddProgressBar(AppNotificationProgressBar value);
function addProgressBar(value)
Public Function AddProgressBar (value As AppNotificationProgressBar) As AppNotificationBuilder

Parameters

value
AppNotificationProgressBar

An AppNotificationProgressBar representing the progress bar to be added to the notification.

Returns

Returns the AppNotificationBuilder instance so that additional method calls can be chained.

Examples

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&apos;s new music...</text>
            <progress title='{progressTitle}' status='{progressStatus}' value='{progressValue}' valueStringOverride='{progressValueString}'/>
        </binding>
    </visual>
</toast>

Remarks

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.

Applies to