AppNotificationBuilder.SetDuration(AppNotificationDuration) Method

Definition

Sets the duration for an app notification.

public:
 virtual AppNotificationBuilder ^ SetDuration(AppNotificationDuration duration) = SetDuration;
AppNotificationBuilder SetDuration(AppNotificationDuration const& duration);
public AppNotificationBuilder SetDuration(AppNotificationDuration duration);
function setDuration(duration)
Public Function SetDuration (duration As AppNotificationDuration) As AppNotificationBuilder

Parameters

duration
AppNotificationDuration

A value from the AppNotificationDuration enumeration specifying the duration for the app notification.

Returns

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

Examples

The following example demonstrates setting the duration in the XML payload for an app notification.

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetDuration(AppNotificationDuration.Long)
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

The resulting XML payload:

<toast duration='long'>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
</toast>

Remarks

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