Pergunta

Is there any way I could change the Uris of the default tile images in the WMAppManifest.xml at runtime?

For example I would like to enable an option for users to select the tile image in the settings of my app. This is not the problem because I can then update the main tile with the new image if the app is pinned to the start, but if the app is not pinned and the user wants to pin the app another time then the default image will be used, and this is not the behavior I want, I want the tile to have the image the user selected in the settings. How to achieve this if possible?

Foi útil?

Solução

I figured it out, I didn't know the ShellTile.ActiveTiles would always contain the default tile, whether the app is pinned or not, so I just updated this tile when the settings item changed:

private async void UpdateTile(bool isTransparent)
    {
        ShellTile defaultTile = ShellTile.ActiveTiles.FirstOrDefault();
        if (defaultTile != null)
        {
            string tileFolder = isTransparent ? "Transparent" : "Normal";

            defaultTile.Update(new FlipTileData()
            {
                SmallBackgroundImage = new Uri("appdata:/Assets/Tiles/" + tileFolder + "/Logo.scale-100.png"),
                BackgroundImage = new Uri("appdata:/Assets/Tiles/" + tileFolder + "/Logo.scale-180.png"),
                WideBackgroundImage = new Uri("appdata:/Assets/Tiles/" + tileFolder + "/WideLogo.scale-180.png")
            });
        }
    }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top