Wednesday, November 13, 2013

Stopping a live tile from flipping

Sometimes you may want to remove the contents (and images) from the back of a [flip] tile to stop it flipping. How to do this isn't always obvious and it can be frustrating to discover that just setting the content to an empty string or null doesn't work.
To stop a tile from flipping you must clear it’s content, not just set it to an empty string.

Unfortunately the FlipTileData class doesn't provide a method or property to make this easy. Instead you must use an XML document that contains appropriate FlipTileDate template information.
Something like this:

var clearTileBackXml = new StringBuilder();

clearTileBackXml.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
clearTileBackXml.Append("");
clearTileBackXml.Append("");
clearTileBackXml.Append("");
clearTileBackXml.Append("");
clearTileBackXml.Append("");
clearTileBackXml.Append("");
clearTileBackXml.Append("");
clearTileBackXml.Append("");

var ftd = new FlipTileData(clearTileBackXml.ToString());

ShellTile.ActiveTiles.First().Update(ftd);

If you’re updating anything other than the primary tile you need to set the Tile ID in the XML as well as select the correct element from the ActiveTiles collection.

For more info and to see the full template go to MSDN.

1 comment:

  1. If you have problems copying the code from here try http://developer.nokia.com/Community/Wiki/How_to_stop_a_live_tile_from_flipping#Solution instead

    ReplyDelete

I get a lot of comment spam :( - moderation may take a while.