AppNotificationButton.SetButtonStyle(AppNotificationButtonStyle) 方法

定义

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

public:
 virtual AppNotificationButton ^ SetButtonStyle(AppNotificationButtonStyle value) = SetButtonStyle;
AppNotificationButton SetButtonStyle(AppNotificationButtonStyle const& value);
public AppNotificationButton SetButtonStyle(AppNotificationButtonStyle value);
function setButtonStyle(value)
Public Function SetButtonStyle (value As AppNotificationButtonStyle) As AppNotificationButton

参数

value
AppNotificationButtonStyle

AppNotificationButtonStyle 枚举中的值,指定按钮的样式。

返回

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

示例

以下示例演示如何检查应用通知按钮样式是否受支持,如果支持,则设置按钮样式。

var button = new AppNotificationButton("Reply")
    .AddArgument("action", "reply");

if(AppNotificationButton.IsButtonStyleSupported())
{
    button.SetButtonStyle(AppNotificationButtonStyle.Critical);
}

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .AddButton(button)
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

如果支持紧急方案,则生成的 XML 有效负载:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <actions>
        <action content='Reply' arguments='action=reply' hint-toolTip='Click to reply.'/>
    </actions>
</toast>

注解

按钮样式仅在 Windows 10 内部版本 19041 及更高版本上受支持。 调用 AppNotificationButton.IsButtonStyleSupported 以确定当前设备上是否支持按钮样式。

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

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

适用于