Deactivating Windows Phone Live Tiles

2 minute read

When alive with activity, the Windows Phone 8 Live Tiles look great. I like the Flip Tile Template, in particular. It’s useful to be able to return them to a dormant state, and its not immediately obvious how to do this. Update your tile template Text and TileUri and your tile will clear its content but remain “alive” and flipping.

This problem carries over from Windows Phone 7 where, to prevent my dormant tiles from spinning, I would force an error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
ShellTile pinnedTile = GetPinnedTile();
StandardTileData dormantTile = GetDormantTile();

StandardTileData invalidTile = dormantTile.BackBackgroundImage = new Uri("/", UriKind.Relative); //this is an invalid uri
pinnedTile.Update(invalidTile); //prevent flipping by causing error

pinnedTile.Update(dormantTile);```

This hack doesn’t work in Windows Phone 8. I came across the suggestion to clear all text fields by setting them to empty strings and clear all Uri by setting them equal to null. I find it easier to use an empty template to be sure all properties are nulled.

```XML
private string FLIP_TEMPLATE_XML = @"<?xml version=""1.0"" encoding=""utf-8""?>
<wp:Notification xmlns:wp=""WPNotification"" Version=""2.0"">
  <wp:Tile Id=""[Tile ID]"" Template=""FlipTile"">
    <wp:SmallBackgroundImage Action=""Clear""></wp:SmallBackgroundImage>
    <wp:WideBackgroundImage Action=""Clear""></wp:WideBackgroundImage>
    <wp:WideBackBackgroundImage Action=""Clear""></wp:WideBackBackgroundImage>
    <wp:WideBackContent Action=""Clear""></wp:WideBackContent>
    <wp:BackgroundImage Action=""Clear""></wp:BackgroundImage>
    <wp:Count Action=""Clear""></wp:Count>
    <wp:Title Action=""Clear""></wp:Title>
    <wp:BackBackgroundImage Action=""Clear""></wp:BackBackgroundImage>
    <wp:BackTitle Action=""Clear""></wp:BackTitle>
    <wp:BackContent Action=""Clear""></wp:BackContent>
  </wp:Tile>
</wp:Notification>"```
And then update the tile to force it to go dormant.

```XML
FlipTileData pinnedTile = GetPinnedTile();
FlipTileData dormantTile = GetDormantTile();

FlipTileData clearTile = new FlipTileData(FLIP_TEMPLATE_XML.Replace("[Tile ID]", "MyTile"));
pinnedTile.Update(clearTile);

pinnedTile.Update(tileData);

This works, but not 100% reliably. A dormant tile will at times, come to life unexpectedly.  I realized that the platform was defeating me after some trial and error.

The problem is that when a live tile is updated, the tile queues up an update to all tile sizes but to be efficient it defers execution of the update until a size needs to be displayed. So, a wide image won’t be downloaded until changing to a wide live tile.  After updating a live tile to a dormant template, changing its size will trigger both the dormant update AND ANY UPDATE ALREADY IN THE QUEUE.

These updates occur asynchronously rather than sequentially. As a result, my update to a dormant tile would happen quickly. The queued update to a flipping tile retrieved images from a remote uri, and so it completed second and the tile remained “live”.

My workaround is to set the tile as dormant every time the application is run, and so the outdated tile eventually works itself out. I don’t yet know of a foolproof way to remove the activity from my live tiles. Do you know of one?

Updated: