The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Multiple Live Tile Update RRS feed

  • Question

  • Hello,

    I am working on a method which has all three tiles ready on user's choice. I think I am Close to get this working, but I can't figure out how to construct the XML payload for the tile notification, any ideas?

    public void UpdateTiles(string smallTileImagePath, string mediumTileImagePath, string wideTileImagePath)
            {
                var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
                tileUpdater.Clear();
    
                var smallTileTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare71x71Image);
                var smallTileImageAttributes = smallTileTemplate.GetElementsByTagName("image");
                ((XmlElement)smallTileImageAttributes.Item(0)).SetAttribute("src", smallTileImagePath);
                
                var mediumTileTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Image);
                var mediumTileImageAttributes = mediumTileTemplate.GetElementsByTagName("image");
                ((XmlElement)mediumTileImageAttributes.Item(0)).SetAttribute("src", mediumTileImagePath);
                
                var wideTileTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Image);
                var wideTileImageAttributes = wideTileTemplate.GetElementsByTagName("image");
                ((XmlElement)wideTileImageAttributes.Item(0)).SetAttribute("src", wideTileImagePath);
    
                var xmlPayload = ?
                var notification = new TileNotification(xmlPayload);
                
                tileUpdater.Update(notification);
            }

    Friday, February 6, 2015 3:31 PM

Answers

  • Read this document carefully: https://msdn.microsoft.com/en-us/library/windows/apps/hh465439.aspx

    This example defines a text-only medium notification using the same text string that we used in the wide notification.

    XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text04);
    
    XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
    squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode("Hello World! My very own tile notification"));

    Next, add the medium tile to the wide tile's payload. Retrieve the binding element that defines the medium tile in the squareTileXml payload. Append that binding element as a sibling of the wide tile.

    IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
    tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

    The preceding steps result in two binding elements under a single visual element in the XML payload, as shown here:

    <tile>
        <visual version="2">
            <binding template="TileWide310x150ImageAndText01" fallback="TileWideImageandText01">
                <image id="1" src="ms-appx:///assets/redWide.png"/>
                <text id="1">Hello World! My very own tile notification</text>
            </binding>
    
            <binding template="TileSquare150x150Text04" fallback="TileSquareText04">
                <text id="1">Hello World! My very own tile notification</text>
            </binding>
        </visual>
    </tile>


    Best Regards,
    Please remember to mark the replies as answers if they help

    Monday, February 9, 2015 6:50 AM