Jimmy Engström

NAVIGATION

Universal apps and NotificationsExtensions - Live Tiles (Part2)

Here is how to handle live tiles the easy way in Universal apps.

First add the “NotificationsExtensions.UniversalApps” Nuget package.

See blog post showing how.


Tile templates comparison:
http://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx


This is how to update your tile with a scheduled update.

//Create wide tile update
ITileWide310x150Text09 tileContent = TileContentFactory.CreateTileWide310x150Text09();
tileContent.TextHeading.Text = "Wide Tile Text";
tileContent.TextBodyWrap.Text = "More text on the tile";

//Always add a 150x150 tile update also  
ITileSquare150x150Text04 squareContent = TileContentFactory.CreateTileSquare150x150Text04();
squareContent.TextBodyWrap.Text = "More text on the tile";
tileContent.Square150x150Content = squareContent;


ScheduledTileNotification futureTile = new ScheduledTileNotification(tileContent.GetXml(), DateTime.Now.AddSeconds(15));
TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile);

 

To update your tile right away you can use these lines instead of the last two above:

TileNotification tileNotification=new TileNotification(tileContent.GetXml());
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

 

Recources

Microsofts code sample:

http://code.msdn.microsoft.com/Alarm-toast-notifications-fe81fc74#content

Nuget version

https://www.nuget.org/packages/NotificationsExtensions.UniversalApps/

Posted in Windows Phone