I am able to update the tile once it is pinned, but not when it is not pinned.
This is the code and I am not able to understand where the problem could be. I appreciate if somebody who played extensively can help me out.
ShellTile primaryTile = ShellTile.ActiveTiles.First();
ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("TileID=2"));
StandardTileData newTileData = new StandardTileData
{
Blah; //Setting the background
};
if (primaryTile != null)
{
primaryTile.Update(newTileData);
}
else
{
//test if Tile was created
if (tileToFind == null)
{
ShellTile.Create(new Uri("/MainPage.xaml?TileID=2", UriKind.Relative), newTileData);
}
else
{
tileToFind.Update(newTileData);
}
}
As I remember, main tile is always exists (even if it not pinned), so
primaryTileis always notnull. So, your secondary tile is never created with your code.