AppNotificationButton.IsButtonStyleSupported 方法

定义

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

public:
 static bool IsButtonStyleSupported();
 static bool IsButtonStyleSupported();
public static bool IsButtonStyleSupported();
function isButtonStyleSupported()
Public Shared Function IsButtonStyleSupported () As Boolean

返回

Boolean

bool

如果支持按钮样式,则为 True;否则为 false。

示例

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

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

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

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

AppNotificationManager.Default.Show(builder.BuildNotification());

如果支持紧急方案,则生成的 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>

注解

AppNotificationButton.SetButtonStyle 方法允许指定 AppNotificationButtonStyle 枚举中的按钮样式之一,为常见方案提供一致的体验。 此功能仅在 Windows 10 内部版本 19041 及更高版本上受支持。 使用此方法可在运行时确定当前设备上是否支持按钮样式。

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

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

适用于