AppNotificationBuilder.AddProgressBar(AppNotificationProgressBar) 方法

定义

将进度栏添加到应用通知的 XML 有效负载。

public:
 virtual AppNotificationBuilder ^ AddProgressBar(AppNotificationProgressBar ^ value) = AddProgressBar;
AppNotificationBuilder AddProgressBar(AppNotificationProgressBar const& value);
public AppNotificationBuilder AddProgressBar(AppNotificationProgressBar value);
function addProgressBar(value)
Public Function AddProgressBar (value As AppNotificationProgressBar) As AppNotificationBuilder

参数

value
AppNotificationProgressBar

一个 AppNotificationProgressBar,表示要添加到通知中的进度栏。

返回

返回 AppNotificationBuilder 实例,以便可以链接其他方法调用。

示例

以下示例演示如何将组合框添加到应用通知。

var builder = new AppNotificationBuilder()
        .AddText("Downloading this week's new music...")
        .AddProgressBar(new AppNotificationProgressBar()
            .BindTitle()
            .BindValueStringOverride());

    var data = new AppNotificationProgressData(1 /* Sequence number */);
    data.Title = "Artist Name"; // Binds to {progressTitle} in xml payload
    data.Value = 0.5; // Binds to {progressValue} in xml payload
    data.ValueStringOverride = "1/2 songs"; // Binds to {progressValueString} in xml payload
    data.Status = "Downloading..."; // Binds to {progressStatus} in xml payload

    var notification = builder.BuildNotification();
    notification.Progress = data;

    AppNotificationManager.Default.Show(notification);

生成的 XML 有效负载:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Downloading this week&apos;s new music...</text>
            <progress title='{progressTitle}' status='{progressStatus}' value='{progressValue}' valueStringOverride='{progressValueString}'/>
        </binding>
    </visual>
</toast>

注解

绑定 AppNotificationProgressData 的字段以设置进度栏的初始值和更新状态。 有关数据绑定到应用通知中的进度栏的信息,请参阅 应用通知进度栏和数据绑定

有关使用 AppNotificationBuilder API 创建应用通知 UI 的指导,请参阅 应用通知内容

有关应用通知的 XML 架构的参考信息,请参阅 应用通知内容架构

适用于