问题描述
n windows phone 8 silverlight 应用程序,我们可以在代码中添加/删除磁贴,如下所示
n windows phone 8 silverlight application we can add / remove tiles from the code as below
ShellTile.Create(tileUri, tileData, true);
我们可以得到基于 Uri 的图块,如下所示
and we can get the tiles based on the Uri like below
ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("/"));
我们如何在 windows phone 8.1(通用)应用程序中做类似的事情?
How we can do similarly in windows phone 8.1 (universal) applications?
我无法获得明确的信息或样本.
I could not get clear information or samples.
推荐答案
当你想创建一个磁贴时,你可以像 这个答案:
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();
当你想删除一个磁贴时,你必须找到你的磁贴(例如通过它的ID),然后调用RequestDeleteAsync()
:
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();
一些 MSDN 上的更多信息.
这篇关于如何从代码中添加/删除 Windows phone 8.1(通用)应用程序的默认磁贴/辅助磁贴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!