,

Programmatically Updating Shell Tiles

Both primary and secondary tiles can be updated by your app, either while your app is running in the foreground or from a background agent. Observe the following example:

ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
if (tile != null)
{
    IconicTileData tileData = new IconicTileData
        {
            BackgroundColor = Colors.Cyan
        };
    tile.Update(tileData);
}

Here the app uses the iconic tile template. The tile is retrieved from the static ActiveTiles collection of the ShellTile class. Regardless of whether the app is pinned to the Start Experience, ActiveTiles always contains at least one tile: the app’s primary tile. A tile is updated by creating an instance of a tile data class, which can be of type IconicTileData, FlipTileData, or CycleTileData, depending on the type of tile template you are using.


Note

You cannot update a tile using the ShellTileData class. Furthermore, you can update a tile using only the tile data class corresponding to the tile template. For example, when using the flip tile template, you can update only the tile using a FlipTileData object.


Tiles can be updated programmatically in your foreground app or from a background agent. In Chapter 32 you see how to programmatically create a secondary shell tile and how to update a shell tile using a background task. In Chapter 15, “Receiving Messages from the Cloud Using Push Notification,” you see how to update a tile using push notification and a cloud service.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.255.127