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

标签 xaml uwp windows-store-apps

在我的 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/

相关文章:

wpf - 如何让 DataTemplate.DataTrigger 检查大于或小于?

c# - 如何在 wpf MVVM 中选择文本框的文本

c# - 如何在 UWP 应用程序中通过 log4net 配置日志记录

javascript - 如何处理 Windows 8 WinJS 游戏中的分辨率?

c# - Windows Store App ListView 闪烁/内容消失

c# - 基于模式为 XML 文件创建 WPF 编辑器

javascript - 如何拥有从右到左的文本输入字段

c++ - 使用 CMake 以 C++/WinRT 为目标

c# - XAml Windows 应用商店应用程序中的表

msbuild - 从命令提示符创建 Windows 应用商店应用程序包