TileNotification.ExpirationTime 属性

定义

获取或设置 Windows 从磁贴中删除通知的时间。 默认情况下,磁贴更新不会过期。 最佳做法是显式设置过期时间以避免过时的内容。

public:
 property IReference<DateTime> ^ ExpirationTime { IReference<DateTime> ^ get(); void set(IReference<DateTime> ^ value); };
IReference<DateTime> ExpirationTime();

void ExpirationTime(IReference<DateTime> value);
public System.Nullable<System.DateTimeOffset> ExpirationTime { get; set; }
var iReference = tileNotification.expirationTime;
tileNotification.expirationTime = iReference;
Public Property ExpirationTime As Nullable(Of DateTimeOffset)

属性值

应删除通知的日期和时间。

示例

以下示例使用 ExpirationTime 显示 30 秒的磁贴通知。

function tileNotificationExpiration() {
    var Notifications = Windows.UI.Notifications;
    var tileXml = Notifications.TileUpdateManager.getTemplateContent(Notifications.TileTemplateType.tileWide310x150Text04);

    var currentTime = new Date();
    var seconds = 30;

    var tileTextAttributes = tileXml.getElementsByTagName("text");
    tileTextAttributes[0].appendChild(tileXml.createTextNode("This notification will expire at " + new Date(currentTime.getTime() + seconds * 1000)));

    var tileNotification = new Notifications.TileNotification(tileXml);

    // Set the expiration time on the notification
    var expiryTime = new Date(currentTime.getTime() + seconds * 1000);

    tileNotification.expirationTime = expiryTime;
    Notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification);
}

适用于

另请参阅