Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WP7 Mango: How do I delete a live tile?

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?

like image 518
James Cadd Avatar asked Sep 09 '11 20:09

James Cadd


2 Answers

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);
    }
like image 26
robertk Avatar answered Oct 01 '22 06:10

robertk


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();  
    }  
}  
like image 65
Mattias Cibien Avatar answered Oct 01 '22 06:10

Mattias Cibien