2

I am currently implementing live tiles for my Windows 8 App. Now I want two different tile styles (for the small one and the enlarged one). I tried it like this:

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var tileUpdaterBig = TileUpdateManager.CreateTileUpdaterForApplication();
            tileUpdater.Clear();
            tileUpdaterBig.Clear();
            tileUpdater.EnableNotificationQueue(true);
            tileUpdaterBig.EnableNotificationQueue(true);

            foreach (var item in Articles)
            {
                var xml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
                var bigXML = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText09);
                var textElements = xml.GetElementsByTagName("text");
                var bigTextElements = bigXML.GetElementsByTagName("text");
                textElements[0].AppendChild(xml.CreateTextNode(item.Title));
                bigTextElements[0].AppendChild(bigXML.CreateTextNode(item.Title));
                bigTextElements[1].AppendChild(bigXML.CreateTextNode(item.Preview));
                var notification = new TileNotification(xml);
                var notificationBig = new TileNotification(bigXML);
                tileUpdater.Update(notification);
                tileUpdaterBig.Update(notificationBig);
            } 

Is this the correct way?

Moreover it seems as if there is only some data shown inside the tile, not each element from the list.

Thanks for your help.

Security Hound
  • 2,577
  • 3
  • 25
  • 42
oopbase
  • 11,157
  • 12
  • 40
  • 59
  • What is the output data, what is the input data, why does it seem you have two different data sources instead of a single data source and simply displaying it differently? Why do you clear `tileUpdater` and `tileUpdaterBig` after you create them? How is this code called exactly, if its within a method, that would be bad and a waste of processing power ( to clear the tile each time its updated ). – Security Hound Dec 04 '12 at 16:32
  • Title and Preview are strings. The method is called in the constructor of the MainViewModel. I just don't know how to use it correctly. I found some snippets on the internet and tried to combine them. – oopbase Dec 04 '12 at 16:34
  • That information while help doesn't answer my questions – Security Hound Dec 04 '12 at 16:41
  • @Ramhound OK... It is one datasource. How to display them differently? I clear them because I found a snippet for that online. The code is called when the ViewModel is created. I hope that's enough information. By the way, thanks for your help. – oopbase Dec 04 '12 at 16:43
  • It doesn't seem like you understand what the code is suppose to do. – Security Hound Dec 04 '12 at 16:47
  • It seems as if you understand it. So could you explain it to me? Escpecially show me what exactly I am doing wrong? – oopbase Dec 04 '12 at 16:48
  • No, I don't have enough information and don't have to explain it to you. – Security Hound Dec 04 '12 at 16:53
  • You should only be creating a single `TileUpdater` object for each tile. http://stackoverflow.com/a/12605685/1656796 shows how to specify live tile content for both square and wide tile content in a single notification. – Nathan Kuchta Dec 04 '12 at 16:55
  • 1
    @Ramhound I think you missunderstood me. I was just asking whether you can show me what I am doing wrong. And I don't really know why you downvoted the question. I think there are people out there who faced the same problem with the snipped... – oopbase Dec 04 '12 at 16:55
  • @Forlan07 - This question does appear to show enough research on your part. Even after I had question how you called this code you didn't update the question to provide that information only answered it within a comment. – Security Hound Dec 04 '12 at 17:22

1 Answers1

2

You only need one TileUpdater. Check out the code sample in this article (scroll down to "Here is the final code").

Essentially, since you don't know if the user has put your tile in the square or wide format, you need to send updates for both in one payload.

You should only set EnableNotificationQueue to true if you want the last 5 updates to all scroll through the tile. If you want just the latest update to appear and replace the others, set this to false (or do nothing since false is the default).

Jennifer Marsman - MSFT
  • 5,167
  • 1
  • 25
  • 24