JohnyDgoode
JohnyDgoode

Reputation: 1563

How to update liveTile programatically on Windows8?

I want to update my liveTile when application will enter background.How can I do ??

here is my code to update a liveTile.

    private static TileUpdater updater;        

public static void updateLiveTile(string text)
        {
            if (updater == null)
            {
                updater = TileUpdateManager.CreateTileUpdaterForApplication();
            }
            else
                updater.Clear();

            updater.EnableNotificationQueue(true);

            var tile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);
            tile.GetElementsByTagName("text")[0].InnerText = text;
            XmlNodeList tileImageAttributes = tile.GetElementsByTagName("image");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appdata:///local/MyShop_Image.png");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic");

            updater.Update(new TileNotification(tile));
        }

Upvotes: 1

Views: 1967

Answers (1)

Typist
Typist

Reputation: 1474

Consume App tiles and badges sample and Tile updates from Background Task helpful resources.

Upvotes: 1

Related Questions