9

我正在使用以下代码在设备上创建动态磁贴:

ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
StandardTileData newTileData = new StandardTileData
{
    BackgroundImage = new Uri(string.Format("isostore:{0}", DefaultLiveTilePath), UriKind.Absolute),
    Title = "Test"
};
tile.Update(newTileData);

稍后我想删除动态磁贴图像并在固定时将其恢复为应用程序图标。这可能吗?

4

3 回答 3

6

根据此博客,您应该使用此代码

public void DeleteExistingTile()  
{  
    var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("DetailId=123"));  

    // If the Tile was found, then delete it.  
    if (foundTile != null)  
    {  
        foundTile.Delete();  
    }  
}  
于 2011-09-23T16:36:10.837 回答
3

每次应用程序启动时将我的磁贴重置为正常时,我都使用以下代码:

    private void ResetLiveTileToNormal()
    {
        ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault();


        ShellTileData shellData = new StandardTileData
        {
            Title = "XXXXXXXX",
            Count = 0,
            BackContent = "",
            BackTitle = "",
            BackBackgroundImage = new Uri("", UriKind.Relative),
            BackgroundImage = new Uri(@"/Images/LiveTiles/XXXXXX.png", UriKind.Relative)
        };
        TileToFind.Update(shellData);
    }
于 2011-09-24T16:39:03.160 回答
2

ShellTile.ActiveTiles.FirstOrDefault();已过时。

void clearTile() {

            ShellTileData tileData = new StandardTileData
            {
                Title = "",
                Count = 0,
                BackContent = "",
                BackTitle = "",
                BackBackgroundImage = new Uri("", UriKind.Relative),
                BackgroundImage = new Uri(@"/ApplicationIcon.png", UriKind.Relative)
            };
            IEnumerator<ShellTile> it = ShellTile.ActiveTiles.GetEnumerator();
            it.MoveNext();
            ShellTile tile = it.Current;
            tile.Update(tileData);
        }

基于研究并感谢 robertftw

于 2012-09-12T05:21:21.563 回答