WP7: Updating Live Tiles Locally In Mango

26 August 2011

As you'll no doubt be aware if you've been looking at any of the information around Mango released over the past few months, there's a large number of additional APIs available in the upcoming update release to Windows Phone 7. One of the ones I'm very excited for is the ability to update the live tile for your application locally! This means that for Noborizaka, I no longer have to host an Azure service to generate an image when I can simply do so from the phone itself.

Updating Live Tiles programmatically is extremely simple, too. The basic steps are:

  • Get the main Application Tile. Every app you create has this tile, and this is the tile users see when they pin your application to the Start screen. You can do so like this:

    ShellTile defaultTile = ShellTile.ActiveTiles.First();
    

  • Update the application tile, providing a StandardTileData object. Once you have a reference to the main application tile, you can call the Update() method, providing a StandardTileData object which can contain a BackgroundImage, Title, Count (as well as some other properties for the back of the tile, which is also new to Mango).

    defaultTile.Update(new StandardTileData { BackgroundImage = new Uri("isostore:" + sTilePath, UriKind.Absolute), Title = "Noborizaka" });
    

  • Note that instead of pointing to a BackgroundImage with a Uri to an online image, I'm pointing to an image that I've stored in local isolated storage - I've set up my app so that when it's exiting or being deactivated, it quickly generates the tile image and saves it to isolated storage before the live tile is updated, and it all seems to work quite well. Note that the tile image needs to be stored in a folder '\Shared\ShellContent' for it to be available for tile updates.

    If you'd like to read more on live tile updating (such as updating the back of the live tile and secondary tiles), check out this MSDN Article. You can also check out how to generate live tile images without using the visual tree here (ie, elements that aren't being rendered directly onto your application).

    Tags: live tiles, Mango, Noborizaka, wp7

    Add a Comment

    No Comments