Live Tiles are not new from Microsoft. We already have Live Tiles introduced in Windows Mobile 7 interfaces. Live tiles in Metro applications work more or less similar to what has been there in WP7. When you open Windows 8 Tablet, you will see a number of Tiles that hold up the entire screen, which are multi touch sensitive and also easily customization with hand. These tiles not only important to launch the application, but you can also register a handler to update the tiles from within your code.
To do, we consider three classes mainly.
1. TileUpdateManager : Manages the Tile Updater, can get you TileUpdater for the current application.
For instance
var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
This will get the current application TileUpdater.
2. TileUpdater : This object lets you update tiles with notifications.
3. TileNotification : Prepresents an update block for a tile.
Lets add a simple TileUpdater :
private void Button_Click(object sender, RoutedEventArgs e) { TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Clear(); updater.EnableNotificationQueue(true); this.SendNotification(); } private void SendNotification() { var tile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText03); var attr= tile.GetElementsByTagName("text"); attr[0].AppendChild(tile.CreateTextNode(DateTime.Now.ToString())); var tilenotification = new TileNotification(tile); TileUpdateManager.CreateTileUpdaterForApplication().Update(tilenotification); }
Here the Templte represents an XML object that happens to be forming the UI. Generally if you use Javascript it would be lot easier to handle this, but for C#, you need to create a TextNode in the xml and send it using the TileUpdater. The TileUpdater then notify the Live tile to update with the data.
Here when the button is clicked it updates the live tile to show current DateTime.
I hope this post comes handy. You can also read my other articles like
Understanding basic WinRT Metro Applications and Application Capabilities
Layout adjustments Snapping and OrientationChanges in Metro Applications
I hope these comes to you handy.
Thank you for reading.