WP7 Mango:如何删除动态磁贴?

发布于 2024-12-04 00:29:17 字数 356 浏览 2 评论 0原文

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

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

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

I'm creating a live tile on the device with the following code:

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

At a later point I would like to delete the live tile image and have it revert to the app icon when pinned. Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

提笔书几行 2024-12-11 00:29:17

根据此博客 你应该使用此代码

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();  
    }  
}  

According to this blog you shoudl use this code

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();  
    }  
}  
月野兔 2024-12-11 00:29:17

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

    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);
    }

I'm using the following code when resetting my tile back to normal everytime the app starts:

    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);
    }
染火枫林 2024-12-11 00:29:17

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

ShellTile.ActiveTiles.FirstOrDefault(); is obsolete.

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);
        }

Based on research and thanks to robertftw

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文