How to add / remove default tile / secondary tile for Windows phone 8.1 (universal) applications from code?

烂漫一生 提交于 2019-12-10 16:19:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/25564549/how-to-add-remove-default-tile-secondary-tile-for-windows-phone-8-1-univers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!