共用方式為


AppNotificationProgressBar.BindTitle 方法

定義

public:
 virtual AppNotificationProgressBar ^ BindTitle() = BindTitle;
AppNotificationProgressBar BindTitle();
public AppNotificationProgressBar BindTitle();
function bindTitle()
Public Function BindTitle () As AppNotificationProgressBar

傳回

傳回 AppNotificationProgressBar 實例,以便鏈結其他方法呼叫。

範例

下列範例說明如何使用數據系結,設定應用程式通知進度列的 Title 屬性。

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

備註

AppNotificationProgressData 物件指派給 AppNotification.Progress属性,以更新系結標題值。

您也可以使用 AppNotificationProgressBar.Title 屬性或呼叫 AppNotificationProgressBar.SetStatus來設定標題。

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

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

適用於