简体   繁体   中英

How to create live tiles on UWP

I need an example of creating live tiles on uvp. The documentation doesn't say or i missed how i need to update the tile. Just a sample code, but I don't understand where to insert it.

I need an example of creating live tiles on uvp. The documentation doesn't say or i missed how i need to update the tile.

Please check this Update a live tile from a background task document. We could use CreateTileUpdaterForApplication() to get this updater for tile system. and use Update method to update tile system.

private static void UpdateTile( SyndicationFeed feed )
    {
        // Create a tile update manager for the specified syndication feed.
        var updater = TileUpdateManager.CreateTileUpdaterForApplication();
        updater.EnableNotificationQueue( true );
        updater.Clear();

        // Keep track of the number feed items that get tile notifications.
        int itemCount = 0;

        // Create a tile notification for each feed item.
        foreach( var item in feed.Items )
        {
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent( TileTemplateType.TileWide310x150Text03 );

            var title = item.Title;
            string titleText = title.Text == null ? String.Empty : title.Text;
            tileXml.GetElementsByTagName( textElementName )[0].InnerText = titleText;

            // Create a new tile notification.
            updater.Update( new TileNotification( tileXml ) );

            // Don't create more than 5 notifications.
            if( itemCount++ > 5 ) break;
        }
    }

And this official code sample that you could refer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM