gpt4 book ai didi

xaml - 图像正在 UWP 应用程序中缓存

转载 作者:行者123 更新时间:2023-12-04 03:05:17 24 4
gpt4 key购买 nike

在我的 UWP 应用程序中,我正在绑定(bind)来自 azure 的图像。它在收到响应时被缓存。当我更改 azure 中的图像时,它不会反射(reflect)在我的 UI 中,而是显示来自缓存的图像。
有什么方法可以清除我的 UWP 应用程序的缓存或限制应用程序缓存图像?

最佳答案

你试过CreateOptions="IgnoreImageCache" ?

<Image>
<Image.Source>
<BitmapImage UriSource="{Binding Url}"
CreateOptions="IgnoreImageCache"
DecodePixelWidth="120"
DecodePixelHeight="120" />
</Image.Source>
</Image>

但请确保设置正确的解码像素宽度/高度以避免使用不必要的内存。

根据 documentation -

You should only use BitmapCreateOptions.IgnoreImageCache in cases where you know that the source image file as retrieved by Uniform Resource Identifier (URI) has the potential to change over time. Otherwise, setting CreateOptions to use BitmapCreateOptions.IgnoreImageCache causes all newly retrieved image sources to be decoded again, which can negatively impact performance.



所以也许尝试设置 None作为 CreateOptions 的默认值,并且仅将其更新为 IgnoreImageCache一旦您绝对确定图像已由云更新。备注 CreateOptions也是 dependency property ,因此您也应该能够使用数据绑定(bind)。

关于xaml - 图像正在 UWP 应用程序中缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45143530/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com