AppNotificationButton 类

定义

表示在应用通知上显示的按钮。

public ref class AppNotificationButton sealed
/// [Windows.Foundation.Metadata.Activatable(Microsoft.Windows.AppNotifications.Builder.IAppNotificationButtonFactory, 65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
/// [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 AppNotificationButton final
[Windows.Foundation.Metadata.Activatable(typeof(Microsoft.Windows.AppNotifications.Builder.IAppNotificationButtonFactory), 65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
[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 AppNotificationButton
function AppNotificationButton(content)
Public NotInheritable Class AppNotificationButton
继承
Object Platform::Object IInspectable AppNotificationButton
属性

示例

以下示例演示如何将按钮添加到应用通知的 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.AddButton,将按钮添加到应用通知的 XML 有效负载。 最多可以向单个应用通知添加 5 个按钮。

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

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

构造函数

AppNotificationButton()

初始化 AppNotificationButton 类的新实例。

AppNotificationButton(String)

使用指定的按钮文本初始化 AppNotificationButton 类的新实例。

属性

Arguments

获取或设置与 AppNotificationButton 关联的参数。

ButtonStyle

获取或设置按钮的样式。

Content

获取或设置 AppNotificationButton 的按钮文本。

ContextMenuPlacement

获取或设置一个值,该值指定按钮是否显示在应用通知上下文菜单中。

Icon

获取或设置 AppNotificationButton 的图标。

InputId

获取或设置 AppNotificationButton 的输入 ID。

InvokeUri

获取或设置在单击应用通知按钮时启动的 URI。

TargetAppId

获取或设置在单击应用通知按钮时启动应用的包系列名称 (PFN) 。

ToolTip

获取或设置应用通知按钮的工具提示文本。

方法

AddArgument(String, String)

将由键/值对组成的参数添加到应用通知按钮的 XML 有效负载。

IsButtonStyleSupported()

返回一个值,该值指示当前设备上的应用通知按钮是否支持按钮样式。

IsToolTipSupported()

返回一个值,该值指示当前设备上的应用通知按钮是否支持工具提示。

SetButtonStyle(AppNotificationButtonStyle)

设置应用通知按钮的按钮样式。

SetContextMenuPlacement()

请求将应用通知按钮放置在通知的上下文菜单中。

SetIcon(Uri)

设置 AppNotificationButton 的图标。

SetInputId(String)

设置 AppNotificationButton 的输入 ID。

SetInvokeUri(Uri)

设置在单击应用通知按钮时启动的 URI。

SetInvokeUri(Uri, String)

设置单击应用通知按钮时启动的 URI,并提供的包系列名称 (PFN) 以消除歧义。

SetToolTip(String)

设置应用通知按钮的工具提示文本。

适用于