Share via


AppNotificationProgressBar.BindTitle Method

Definition

public:
 virtual AppNotificationProgressBar ^ BindTitle() = BindTitle;
AppNotificationProgressBar BindTitle();
public AppNotificationProgressBar BindTitle();
function bindTitle()
Public Function BindTitle () As AppNotificationProgressBar

Returns

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

Examples

The following example illustrates how to set the Title property of an app notification progress bar using data binding.

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

Update the bound title value by assigning an AppNotificationProgressData object to the AppNotification.Progresss property.

You can also set the title with the AppNotificationProgressBar.Title property or by calling AppNotificationProgressBar.SetStatus).

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