If you are developing an application or game for Windows 8, making sure you have an engaging, inviting, or informative live tile is an absolute must. I am always surprised when I see the amount of effort a developer puts into their application, but then neglects to spend any time on their live tile. A live tile is a unique way to engage the consumer while they are not using your application. It is not only a way to entertain, but done right, it will drive them back into your application or game time and time again. In this series, we will discuss the many aspects of Live Tiles, from what should be placed on your live tile, to utilizing Azure and Push Notifications to send data to your application.
- Creating A Live Tile that is Engaging and Inviting
- Working with Live Tiles Locally
- Rotating Live Tiles to keep interest (This Post)
- Modifying Live Tiles in a Background Process
- Using Azure and Push Notifications with Live Tiles
Change the Scenery
In addition to inviting them into your application, you want to make sure that the information on your live tile does not become static. While it may engage them once, fresh content is important to keep them engaged. You can rotate up to 5 different tiles at a time. To begin, we will use the project we created in the last post (if you don’t have that, you can create a new project and follow along)
This time we will be adding the code that goes behind the Rotate Tiles button.
Double click on the Rotate Tiles button to get to the button click handler. Add the following code inside the click handler.
AddTileNotification("Title 1", "This is the message for number 1","1");AddTileNotification("Title 2", "This is the message for number 2", "2");AddTileNotification("Title 3", "This is the message for number 3", "3");AddTileNotification("Title 4", "This is the message for number 4", "4");AddTileNotification("Title 5", "This is the message for number 5", "5");
For now, you will get an error stating that AddTileNotification does not exist. We will add that shortly. First add the following declaration to the top of your class.
TileUpdater tileUpdater;
Now in the constructor add the following code
tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();tileUpdater.EnableNotificationQueue(true);
This will new up an instance of the TileUpdateManager and will enable notification queuing.
Now lets add the AddTileNotification method.
private void AddTileNotification(string title, string message, string tag){ var templateType = TileTemplateType.TileWideSmallImageAndText04; var xml = TileUpdateManager.GetTemplateContent(templateType); var textNodes = xml.GetElementsByTagName("text"); textNodes[0].AppendChild(xml.CreateTextNode(title)); textNodes[1].AppendChild(xml.CreateTextNode(message)); //IMPORTANT if the image is not found, this update will fail SILENTLY var imageNodes = xml.GetElementsByTagName("image"); var elt = (XmlElement)imageNodes[0]; elt.SetAttribute("src", "ms-appx:///Assets/SmallLogo.png"); var tile = new TileNotification(xml); tile.Tag = tag; tileUpdater.Update(tile); }
Since we already covered most of this code in the previous post (http://thesociablegeek.com/windows-8/livetiles/working-with-live-tiles-locally/) we will just discuss what is different
DON’T PAST THIS CODE.. IT IS ALL ABOVE, THIS IS JUST FOR DISCUSSION
If we look at the method signature we can see that we are taking in a title, message, and a tag,
private void AddTileNotification(string title, string message, string tag)
The title and message will be used to hydrate the xml we are using for the tile (again see last post for more detail). Since you are only able to rotate 5 tiles at any given time, the tag property allows us to have a reference to the tile we want to replace. If you don’t use the tag property, it will replace the first tile that was added (FIFO). You can see where we apply the tag here
tile.Tag = tag;
If you run the project and click the Rotate Tiles button, you can see that it will rotate through all of the tiles we created. If you want to replace a tile, add another button to the form and add the following to its button click handler.
AddTileNotification("Title 6", "This is the message for number 6", "2");
YSFZGeWBQRaQJyZPLn 7971
Those cupcakes seem fantastic, would just really like just one with my cup of tea, I will just really need to settle for my Kitkat
So EXCACTLY what did the Rock N’ Roll Hall of Fame say?
Wedding Dresses 2012|Wedding Dress| Wholesale Wedding Dresses…
It is really a shame you do not have a donate button! I’d most absolutely donate to this fantastic weblog! I suppose for now i’ll settle for bookmarking and incorporating your RSS feed to my Google account. I glance forward to new updates and can talk concerning this web page with my Facebook group. Talk shortly!
Thank you for every other wonderful article. The place else may just anyone get that kind of info in such a perfect means of writing? I’ve a presentation subsequent week, and I am at the search for such information.
obviously like your web-site but you have to check the spelling on several of your posts. Many of them are rife with spelling issues and I to find it very troublesome to inform the reality however I’ll definitely come again again.
I love your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you? Plz answer back as I’m looking to create my own blog and would like to know where u got this from. appreciate it
Your weblog is very educational, keep up the good writing!!!!
Mr/Ms NG, you probably did not name any movie designed by, when you say persons in pakistan, who have produced any movie the place Hindu or Christian gods are insulted.. Kindly examine prior to you pen down everything and do not mold the facts. The fact is the fact that a Muslim will under no circumstances denounce any other prophets, be it Christians or Jews etc..
Do you mind if I quote a few of your posts as long as I provide credit and sources back to your weblog? My blog is in the exact same area of interest as yours and my visitors would certainly benefit from some of the information you present here. Please let me know if this alright with you. Thank you!
Some will do it on the market aware of niche service offering may require other search marketing and online advertising. A robot.txt file may result in making your website receives a “credit” for those keywords. Each time a visitor clicks on that link, your website URL or page URL, within links, within your main headings or other key headings, within your content. {||||
Thank you repeatedly for the article post.Bless you Again. Really Great.
Advantageous Information About Cheap Framed Art Prints And Their Benefits To Community
Real nice design and superb content material , practically nothing else we want : D.
Please let me know if you’re looking for a writer for your blog. You have some really good posts and I feel I would be a good asset. If you ever want to take some of the load off, I’d really like to write some articles for your blog in exchange for a link back to mine. Please blast me an e-mail if interested. Thank you!
Rather entertaining many thanks, I believe your visitors could possibly want significantly more posts similar to this carry on the very good work.
These are only few of the electric engine! And in some cities, may be more numerous than human-powered bicycles.
I’ve been surfing online greater than three hours these days, yet I by no means found any fascinating article like yours. It is lovely worth enough for me. In my opinion, if all webmasters and bloggers made just right content as you did, the net can be much more helpful than ever before.
Wow that was strange. I just wrote an really long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say fantastic blog!
Graphics are truly fastidious source of lessons instead of wording, its my knowledge, what would you say?
Hey just wanted to give you a brief heads up and let you know a few of the images aren’t loading properly. I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same results.
We are a bunch of volunteers and opening a new scheme in our community. Your web site offered us with useful information to work on. You’ve performed a formidable task and our whole group can be thankful to you.
Pretty component of content. I just stumbled upon your website and in accession capital to say that I get actually loved account your weblog posts. Any way I’ll be subscribing in your augment and even I success you access persistently rapidly.
Simply desire to say your article is as amazing. The clearness in your post is simply cool and i can assume you are an expert on this subject. Well with your permission let me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please keep up the enjoyable work.
For most up-to-date news you have to visit world-wide-web and on the web I found this web site as a finest website for most recent updates.
I think other web site proprietors should take this site as an model, very clean and great user genial style and design, let alone the content. You’re an expert in this topic!
I went over this internet site and I conceive you have a lot of fantastic information, saved to fav (:.
The ideal manager will participate in the process of staff in the organization. Quantity pertains to the candidate’s personality. According to WCBS, last year the NYPD hired 2,983 but lost 3,290 officers to retirements, resignations, and attrition. Applicants also consider whether or not they are appropriate for an interview.
Real instructive and wonderful structure of subject material, now that’s user pleasant (:.
Median COO’s brought home $4.6-7.6 million. Home builders and developers will need homes maintained, especially with winterization in the event of a covered peril. For example, some companies won’t cover it.
I have not checked in here for some time since I thought it was getting boring, but the last several posts are really great quality so I guess I’ll add you back to my daily bloglist. You deserve it my friend.
Excellent post, thanks for the good read. You really helped me comprehend this subject much better.