AppNotificationBuilder.AddButton(AppNotificationButton) 方法

定义

将按钮添加到应用通知。

public:
 virtual AppNotificationBuilder ^ AddButton(AppNotificationButton ^ value) = AddButton;
AppNotificationBuilder AddButton(AppNotificationButton const& value);
public AppNotificationBuilder AddButton(AppNotificationButton value);
function addButton(value)
Public Function AddButton (value As AppNotificationButton) As AppNotificationBuilder

参数

value
AppNotificationButton

一个 AppNotificationButton 对象,该对象表示要添加到通知中的按钮。

返回

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

示例

以下示例演示如何将按钮添加到应用通知的 XML 有效负载。

var notification = new AppNotificationBuilder()
    .AddText("Send a message.")
    .AddTextBox("textBox")
    .AddButton(new AppNotificationButton("Send")
        .AddArgument("action", "sendMessage"))
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

生成的 XML 有效负载:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Send a message.</text>
        </binding>
    </visual>
    <actions>
        <input id='textBox' type='text'/><action content='Send' arguments='action=sendMessage'/>
    </actions>
</toast>

注解

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

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

适用于