Freigeben über


AppNotificationProgressBar Klasse

Definition

Stellt eine Statusleiste dar, die in einer App-Benachrichtigung angezeigt wird.

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
Vererbung
Object Platform::Object IInspectable AppNotificationProgressBar
Attribute

Beispiele

Im folgenden Beispiel wird das Hinzufügen einer Statusleiste zur XML-Nutzlast für eine App-Benachrichtigung veranschaulicht.

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

Der folgende Screenshot zeigt eine App-Benachrichtigung mit einer Statusleiste.

Screenshot einer App-Benachrichtigung mit einer Statusleiste.

Fügen Sie der XML-Nutzlast für eine App-Benachrichtigung eine Statusleiste hinzu, indem Sie AppNotificationBuilder.AddProgressBaraufrufen.

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.

Konstruktoren

AppNotificationProgressBar()

Initialisiert eine neue Instanz der AppNotificationProgressBar Klasse.

Eigenschaften

Status

Dient zum Abrufen oder Festlegen des Statustexts einer App-Benachrichtigungsstatusleiste.

Title

Dient zum Abrufen oder Festlegen eines Titeltexts einer App-Benachrichtigungsstatusleiste.

Value

Dient zum Abrufen oder Festlegen des Statuswerts einer App-Benachrichtigungsstatusanzeige.

ValueStringOverride

Dient zum Abrufen oder Festlegen der Wertzeichenfolgenüberschreibung einer Statusleiste für App-Benachrichtigungen.

Methoden

BindStatus()

Bindet die eigenschaft AppNotificationProgressBar.Status.

BindTitle()

Bindet die eigenschaft AppNotificationProgressBar.Title.

BindValue()

Bindet die eigenschaft AppNotificationProgressBar.Value.

BindValueStringOverride()

Bindet die AppNotificationProgressBar.ValueStringOverride-Eigenschaft.

SetStatus(String)

Legt den Statustext einer App-Benachrichtigungsstatusleiste fest.

SetTitle(String)

Legt den Titeltext einer App-Benachrichtigungsstatusleiste fest.

SetValue(Double)

Legt den Statuswert einer App-Benachrichtigungsstatusanzeige fest.

SetValueStringOverride(String)

Legt die Außerkraftsetzung der Wertzeichenfolge einer Statusleiste für App-Benachrichtigungen fest.

Gilt für: