locked
Peek tile TileSquarePeekImageAndText03 is not showing image but shows the text RRS feed

  • Question

  • Hi. I am building live tiles for my app. I use composite tile update, wide tile + square tile, for square tile I use TileSquarePeekImageAndText03 template.

    Both wide tile and square tile use the same image Logo.png, stored under Assets in my solution. This Logo.png is also used a default logo for square tile (when no updates happened yet). I build a square tile XML this way:

     XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquarePeekImageAndText03);
                XmlNodeList squareTileImage = tileXML.GetElementsByTagName("image");
                ((XmlElement)squareTileImage[0]).SetAttribute("src", "ms-appx:///Assets/Logo.png");
                XmlNodeList squareTileText = squareTileXml.GetElementsByTagName("text");
                squareTileText[0].InnerText = newValue;
                squareTileText[1].InnerText = "SECONDS LEFT";
                var bindingElementSquare = (XmlElement)squareTileXml.GetElementsByTagName("binding").Item(0);
                bindingElementSquare.SetAttribute("branding", "none");
    After update happens I see that peek animation happens, but no Image is shown on square tile, just nothing is shown. But when this 'nothing' flips I successfully see the text supplied. What's wrong? I can imagine that an image is bad, but this same image is used for default square tile and is also used in an update for wide tile, and no issues there.

    Saturday, December 28, 2013 11:38 PM

Answers

  • Actually, I have found the error. When I adjust squareTileXml, I have made a typo in image adjustment.

    I do  XmlNodeList squareTileImage = tileXML.GetElementsByTagName("image");
    While I should do XmlNodeList squareTileImage = squareTileXml.GetElementsByTagName("image");

    • Marked as answer by Anne Jing Monday, January 6, 2014 9:47 AM
    Sunday, December 29, 2013 9:04 AM

All replies

  • What you list here looks reasonable (other than not setting the alt tag on the image), but it's not the whole story. What does the final XML that you pass to your TileNotification look like? Can you share a minimal sample on your SkyDrive showing how you're setting both tiles and demonstrating the problem?

    It should look very similar to the code in the Summary and next steps in Quickstart: Sending a tile update

    --Rob

    Sunday, December 29, 2013 3:18 AM
    Moderator
  • Hi Rob. I would be glad to share this info, but not sure how to convert tileXML to some string which I could copy here. And sorry, I am not sure what you mean under sample? I can show you here the whole code for my tile refresh, it is not big:

    private static void UpdateTile(string newValue)
            {
                //prepared new tile information
                XmlDocument tileXML = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideSmallImageAndText04);
                XmlNodeList tileTextAttributes = tileXML.GetElementsByTagName("text");
                tileTextAttributes[0].InnerText = newValue;
                tileTextAttributes[1].InnerText = "SECONDS LEFT";
                XmlNodeList tileImageAttributes = tileXML.GetElementsByTagName("image");
                ((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///Assets/Logo.png");
                var bindingElementWide = (XmlElement)tileXML.GetElementsByTagName("binding").Item(0);
                bindingElementWide.SetAttribute("branding", "none");
    
                XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquarePeekImageAndText03);
                XmlNodeList squareTileImage = tileXML.GetElementsByTagName("image");
                ((XmlElement)squareTileImage[0]).SetAttribute("src", "ms-appx:///Assets/Logo.png");
                XmlNodeList squareTileText = squareTileXml.GetElementsByTagName("text");
                squareTileText[0].InnerText = newValue;
                squareTileText[1].InnerText = "SECONDS LEFT";
                var bindingElementSquare = (XmlElement)squareTileXml.GetElementsByTagName("binding").Item(0);
                bindingElementSquare.SetAttribute("branding", "none");
    
    
                var node = tileXML.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
                tileXML.GetElementsByTagName("visual").Item(0).AppendChild(node);
    
                var updater = TileUpdateManager.CreateTileUpdaterForApplication();
                updater.EnableNotificationQueue(true);
                updater.Clear();
    
                updater.Update(new TileNotification(tileXML));
            }

    Sunday, December 29, 2013 7:52 AM
  • Actually, I have found the error. When I adjust squareTileXml, I have made a typo in image adjustment.

    I do  XmlNodeList squareTileImage = tileXML.GetElementsByTagName("image");
    While I should do XmlNodeList squareTileImage = squareTileXml.GetElementsByTagName("image");

    • Marked as answer by Anne Jing Monday, January 6, 2014 9:47 AM
    Sunday, December 29, 2013 9:04 AM