Telerik UI for Windows Phone by Progress

This article explains how to update live tiles

Single update

The method GetTile returns a tile associated by the current application linking to the Uri specified as parameter of the method. If a tile is found it can be updated with the method UpdateTile.

Note

Please note that once created the tile creates its template (Flip, Iconic, Cycle or Standard) and this can't be changed with the UpdateTile and CreateOrUpdateTile methods. If you need to change the type of the tile template, you can use find the associated tile with LiveTileHelper's GetTile method, delete it and then create a new tile with the required type. For example if the current tile is with the Iconic tile template, here's how you can change it with the Flip tile template:

CopyC#
ShellTile tile = LiveTileHelper.GetTile(uri);
if (tile != null)
{
    tile.Delete();
}
LiveTileHelper.CreateTile(flipTileData, uri, true);

Multiple updates

If the tile needs to be updated frequently, this can be done in a PeriodicTask. The PeridicTask represents a scheduled task that runs regularly for a small amount of time. It has a method OnInvoke, which is called when the task is invoked and there the tile updating logic can be placed. However, the BackgroundAgents have some restrictions, which prohibit using some of the features that we have in Telerik.Windows.Core assembly. This is why we created a new assembly called Telerik.Windows.BackgroundAgentTools. This is the assembly that needs to be referenced in the Scheduled Task Agent project and the Telerik.Windows.Core assembly should be referenced only in the foreground application where the tile is created. Here is an example:

CopyC#
protected override void OnInvoke(ScheduledTask task)
{
    Deployment.Current.Dispatcher.BeginInvoke(
        () =>
        {
            RadExtendedTileData extendedData = new RadExtendedTileData();
            extendedData.Title = DateTime.Now.ToString();

            foreach (ShellTile tile in ShellTile.ActiveTiles)
            {
                string uri = tile.NavigationUri.ToString();
                if (uri != "/")
                {
                    LiveTileHelper.UpdateTile(tile, extendedData);
                    break;
                }
            }
        });

    NotifyComplete();
}

Each time the task is invoked the tile will be updated with a new tile with the current date and time set for a title. Since the updating of the tile is UI related task, a dispatcher should be used. More detailed explanation and full source code of a sample application is available here.

Note
If you are not familiar with BackgroundAgents, here you can find a step-by-step guide to create an application that uses BackgroundAgents.