Share via


AppNotificationDuration 枚举

定义

指定 AppNotification 的显示持续时间。

public enum class AppNotificationDuration
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract, 65536)]
enum class AppNotificationDuration
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract), 65536)]
public enum AppNotificationDuration
var value = Microsoft.Windows.AppNotifications.Builder.AppNotificationDuration.default
Public Enum AppNotificationDuration
继承
AppNotificationDuration
属性

字段

Default 0

默认持续时间。

Long 1

持续时间长。

示例

以下示例演示如何在应用通知的 XML 有效负载中设置持续时间。

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

AppNotificationManager.Default.Show(notification);

生成的 XML 有效负载:

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

注解

通过调用 AppNotificationBuilder.SetDuration 设置应用通知的持续时间。

适用于