Change default tile image url

半腔热情 提交于 2019-12-25 00:08:40

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/25011753/change-default-tile-image-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!