Sprache

AppNotificationProgressBar.BindValue Methode

Definition

public:
 virtual AppNotificationProgressBar ^ BindValue() = BindValue;
AppNotificationProgressBar BindValue();
public AppNotificationProgressBar BindValue();
function bindValue()
Public Function BindValue () As AppNotificationProgressBar

Gibt zurück

Gibt die AppNotificationProgressBar-Instanz zurück, sodass zusätzliche Methodenaufrufe verkettet werden können.

Beispiele

Das folgende Beispiel veranschaulicht, wie die Value-Eigenschaft einer App-Benachrichtigungsstatusanzeige mithilfe der Datenbindung festgelegt wird.

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);

Die resultierende XML-Nutzlast:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Downloading your weekly playlist...</text>
            <progress title='{progressTitle}' status='{progressStatus}' value='{progressValue}' valueStringOverride='{progressValueString}'/>
        </binding>
    </visual>
</toast>

Aktualisieren Sie die gebundenen Werte durch Aufrufen von AppNotificationManager.UpdateAsync) und angeben Sie das Tag und optional die Gruppe des Tags, das Sie aktualisieren möchten.

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);
}

Hinweise

Der Wert ist standardmäßig gebunden. Aktualisieren Sie den gebundenen Statuswert, indem Sie der Eigenschaft AppNotification.Progressein AppNotificationProgressData-Objekt zuweisen.

Sie können den Wert auch mit der AppNotificationProgressBar.Value-Eigenschaft oder durch Aufrufen von AppNotificationProgressBar.SetValue festlegen.

Anleitungen zur Verwendung der AppNotificationBuilder--APIs zum Erstellen der Benutzeroberfläche für App-Benachrichtigungen finden Sie unter App-Benachrichtigungsinhalt.

Referenzinformationen zum XML-Schema für App-Benachrichtigungen finden Sie unter App-Benachrichtigungsinhaltsschema.

Gilt für: