AppNotificationProgressBar Konstruktor
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Initialisiert einen neuen instance der AppNotificationProgressBar-Klasse.
public:
AppNotificationProgressBar();
AppNotificationProgressBar();
public AppNotificationProgressBar();
function AppNotificationProgressBar()
Public Sub New ()
Beispiele
Das folgende Beispiel veranschaulicht das Hinzufügen einer Statusanzeige zur XML-Nutzlast für eine App-Benachrichtigung.
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, indem Sie AppNotificationManager.UpdateAsync aufrufen und das Tag und optional die Gruppe des Tags angeben, 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
Fügen Sie der XML-Nutzlast für eine App-Benachrichtigung eine Statusleiste hinzu, indem Sie AppNotificationBuilder.AddProgressBar aufrufen.
Eine Anleitung zur Verwendung der AppNotificationBuilder-APIs zum Erstellen der Benutzeroberfläche für App-Benachrichtigungen finden Sie unter App-Benachrichtigungsinhalte.
Referenzinformationen zum XML-Schema für App-Benachrichtigungen finden Sie unter Inhaltsschema für App-Benachrichtigungen.
Gilt für:
Feedback
https://aka.ms/ContentUserFeedback.
Bald verfügbar: Im Laufe des Jahres 2024 werden wir GitHub-Issues stufenweise als Feedbackmechanismus für Inhalte abbauen und durch ein neues Feedbacksystem ersetzen. Weitere Informationen finden Sie unterFeedback senden und anzeigen für