问题描述
限时送ChatGPT账号..有什么办法可以在运行时更改 WMAppManifest.xml 中默认图块图像的 Uris?
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?
推荐答案
我想通了,我不知道 ShellTile.ActiveTiles
将始终包含默认磁贴,无论应用是否固定与否,所以我只是在设置项更改时更新了此磁贴:
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")
});
}
}
这篇关于更改默认磁贴图像 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论