共用方式為


AppNotificationProgressBar 建構函式

定義

初始化 AppNotificationProgressBar 類別的新實例。

public:
 AppNotificationProgressBar();
 AppNotificationProgressBar();
public AppNotificationProgressBar();
function AppNotificationProgressBar()
Public Sub New ()

範例

下列範例示範如何將進度列新增至應用程式通知的 XML 承載。

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

產生的 XML 承載:

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

呼叫 AppNotificationManager.UpdateAsync 並指定要更新之卷標的群組,以更新系結值。

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

備註

呼叫 AppNotificationBuilder.AddProgressBar,將進度列新增至應用程式通知的 XML 承載。

如需使用 AppNotificationBuilder API 來建立應用程式通知 UI 的指引,請參閱 應用程式通知內容

如需應用程式通知 XML 架構的參考資訊,請參閱 應用程式通知內容架構

適用於