Reputation: 301
n windows phone 8 silverlight application we can add / remove tiles from the code as below
ShellTile.Create(tileUri, tileData, true);
and we can get the tiles based on the Uri like below
ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("/"));
How we can do similarly in windows phone 8.1 (universal) applications?
I could not get clear information or samples.
Upvotes: 4
Views: 1533
Reputation: 29792
When you want to create a tile, you can do it as 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();
When you want to delete a tile, then you will have to find your tile (for example by its ID), then call RequestDeleteAsync()
:
SecondaryTile tile = (await SecondaryTile.FindAllAsync()).FirstOrDefault((t) => t.TileId == "your tile's ID");
if (tile != null) await tile.RequestDeleteAsync();
Some more information at MSDN.
Upvotes: 6