AppNotificationButton.IsButtonStyleSupported Method

Definition

Returns a value indicating whether button styles are supported for app notification buttons on the current device.

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

Returns

Boolean

bool

True if button styles are supported; otherwise, false.

Examples

The following example demonstrates checking to see if the app notification button styles are supported and if so, setting the button style.

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());

The resulting XML payload if the urgent scenario is supported:

<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>

Remarks

The AppNotificationButton.SetButtonStyle method allows you to specify one of the button styles from the AppNotificationButtonStyle enumeration to provide a consistent experience for common scenarios. This feature is only supported for on Windows 10 Build 19041 and later. This method allows you to determine at runtime if button styles are supported on the current device.

For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.

For reference information about the XML schema for app notifications, see App notification content schema.

Applies to