Share via


AppNotificationButton.SetButtonStyle(AppNotificationButtonStyle) Method

Definition

Sets the button style for the app notification button.

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

Parameters

value
AppNotificationButtonStyle

A value from the AppNotificationButtonStyle enumeration specifying the style for the button.

Returns

Returns the AppNotificationButton instance so that additional method calls can be chained.

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 notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .AddButton(button)
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

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

Button styles are only supported for on Windows 10 Build 19041 and later. Call AppNotificationButton.IsButtonStyleSupported 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