AppNotificationProgressBar Klasse

Definition

Stellt eine Statusanzeige 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

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

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

Screenshot einer App-Benachrichtigung mit einer Statusanzeige.

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.

Konstruktoren

AppNotificationProgressBar()

Initialisiert einen neuen instance der AppNotificationProgressBar-Klasse.

Eigenschaften

Status

Ruft den status Text einer App-Benachrichtigungsstatusleiste ab oder legt diese fest.

Title

Ruft den Titeltext einer Statusleiste einer App-Benachrichtigung ab oder legt einen fest.

Value

Ruft den Statuswert einer App-Benachrichtigungsstatusleiste ab oder legt diese fest.

ValueStringOverride

Ruft die Wertzeichenfolgenüberschreibung einer Statusanzeige für App-Benachrichtigungen ab oder legt diese fest.

Methoden

BindStatus()

Bindet die AppNotificationProgressBar.Status-Eigenschaft .

BindTitle()

Bindet die AppNotificationProgressBar.Title-Eigenschaft .

BindValue()

Bindet die AppNotificationProgressBar.Value-Eigenschaft .

BindValueStringOverride()

Bindet die AppNotificationProgressBar.ValueStringOverride-Eigenschaft .

SetStatus(String)

Legt den status Text einer Statusanzeige für app-Benachrichtigungen fest.

SetTitle(String)

Legt den Titeltext einer Statusanzeige einer App-Benachrichtigung fest.

SetValue(Double)

Legt den Statuswert einer App-Benachrichtigungsstatusanzeige fest.

SetValueStringOverride(String)

Legt die Wertzeichenfolgenüberschreibung einer Statusanzeige für App-Benachrichtigungen fest.

Gilt für: