TileNotification 类

定义

定义磁贴的更新,包括其视觉对象、标识标记和过期时间。

public ref class TileNotification sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Notifications.ITileNotificationFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
class TileNotification final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Notifications.ITileNotificationFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class TileNotification final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Notifications.ITileNotificationFactory, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class TileNotification final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Notifications.ITileNotificationFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
public sealed class TileNotification
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Notifications.ITileNotificationFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class TileNotification
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Notifications.ITileNotificationFactory), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class TileNotification
function TileNotification(content)
Public NotInheritable Class TileNotification
继承
Object Platform::Object IInspectable TileNotification
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

以下示例使用 TileNotification 构造函数创建新实例,然后使用 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);
}

构造函数

TileNotification(XmlDocument)

创建并初始化 TileNotification 对象的新实例,以便与 TileUpdater 一起使用。

属性

Content

获取通知内容的 XML 说明,然后可以对其进行操作以更改通知。

ExpirationTime

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

Tag

获取或设置一个字符串,Windows 可以使用该字符串来防止重复的通知内容出现在队列中。

适用于

另请参阅