TileNotification TileNotification TileNotification TileNotification Class

Defines an update to a tile, including its visuals, identification tag, and expiration time.

Syntax

Declaration

public sealed class TileNotificationpublic sealed class TileNotificationPublic NotInheritable Class TileNotificationpublic sealed class TileNotification

Remarks

Examples

The following example uses the @Windows.UI.Notifications.TileNotification.#ctor(Windows.Data.Xml.Dom.XmlDocument) constructor to create a new instance, then uses the ExpirationTime property to show a tile notification for 30 seconds.


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);
}

Constructors summary

Creates and initializes a new instance of the TileNotification object for use with a TileUpdater.

Properties summary

Gets the XML description of the notification content, which you can then manipulate to alter the notification.

Gets or sets the time that Windows will remove the notification from the tile. By default, a tile update does not expire. It is a best practice to explicitly set an expiration time to avoid stale content.

Gets or sets a string that Windows can use to prevent duplicate notification content from appearing in the queue.

Constructors

  • TileNotification(XmlDocument)
    TileNotification(XmlDocument)
    TileNotification(XmlDocument)
    TileNotification(XmlDocument)

    Creates and initializes a new instance of the TileNotification object for use with a TileUpdater.

    public TileNotification(XmlDocument content)public New(XmlDocument content)Public Sub New(content As XmlDocument)public TileNotification(XmlDocument content)

    Parameters

Properties

  • Content
    Content
    Content
    Content

    Gets the XML description of the notification content, which you can then manipulate to alter the notification.

    public XmlDocument Content { get; }public XmlDocument Content { get; }Public ReadOnly Property Content As XmlDocumentpublic XmlDocument Content { get; }

    Property Value

    Remarks

    The retrieved elements and their attributes are manipulated through Document Object Model (DOM) manipulation functions to customize the tile content. See tile schema for an explanation of tile elements and attributes found in the XML document.

  • ExpirationTime
    ExpirationTime
    ExpirationTime
    ExpirationTime

    Gets or sets the time that Windows will remove the notification from the tile. By default, a tile update does not expire. It is a best practice to explicitly set an expiration time to avoid stale content.

    public IReference<DateTime> ExpirationTime { get; set; }public IReference<DateTime> ExpirationTime { get; set; }Public ReadWrite Property ExpirationTime As IReference<DateTime>public IReference<DateTime> ExpirationTime { get; set; }

    Property Value

    • The date and time that the notification should be removed.

    Remarks

    Examples

    The following example uses ExpirationTime to show a tile notification for 30 seconds.

    
    
    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);
    
    }
    
  • Tag
    Tag
    Tag
    Tag

    Gets or sets a string that Windows can use to prevent duplicate notification content from appearing in the queue.

    public string Tag { get; set; }public string Tag { get; set; }Public ReadWrite Property Tag As stringpublic string Tag { get; set; }

    Property Value

    • string
      string
      string
      string

      A string of 16 characters or less (plus a terminating null character) that identifies the notification in the stack. While there is no set form to the string content, we recommend that it should relate to the content of the notification.

    Remarks

    Use tags to replace notifications in the stack. If a new notification arrives with the same tag as an existing notification, the new notification replaces the old. For instance, if your tile shows stock prices, you want to show the most up-to-date info. An existing stock price update waiting in the queue to be displayed should be replaced by the latest quotes rather than showing them one after the other.

    A new notification with a matching tag replaces any existing notification with the same tag, but the new notification does not necessarily inherit the older notification's place in the queue.

    The tag should relate to the content of the notification. For example, a notification in a stock quote app could use the stock symbol (such as "msft") while a weather app notification could be tagged with the zip code (such as "98052") of the forecast. Do not simply number your notifications as "notification1", "notification2" and so on.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.UI.Notifications.dll