How to add / remove tiles / secondary tiles for Windows Phone 8.1 (universal) applications from code?

n Windows Phone 8 silverlight application we can add / remove tiles from the code below

ShellTile.Create(tileUri, tileData, true);

and we can get Uri-based tiles as shown below

ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("/"));

How can we do the same in Windows Phone 8.1 (universal) applications?

I could not get clear information or samples.

+4
source share
1 answer

If you want to create a tile, you can do it like in this answer :

SecondaryTile tileData = new SecondaryTile()
{
    TileId = "MyTileID",
    DisplayName = "MyTilesTitle",
    Arguments = "Some arguments"
};
tileData.VisualElements.Square150x150Logo = new Uri("uri to image");
await tileData.RequestCreateAsync();

If you want to delete a fragment, you will need to find your tile (for example, by its identifier), and then call RequestDeleteAsync():

SecondaryTile tile = (await SecondaryTile.FindAllAsync()).FirstOrDefault((t) => t.TileId == "your tile ID");
if (tile != null) await tile.RequestDeleteAsync();

MSDN.

+6

All Articles