更改默认磁贴图像 url

编程入门 行业动态 更新时间:2024-10-28 18:31:47
本文介绍了更改默认磁贴图像 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-25 15:47:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1118581.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:贴图   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!