当 URI 保持不变但图像数​​据发生变化时,windows phone 应用上的图像未更新

Image on windows phone app is not updating when URI remains same but image data is change

我正在用 C# 构建一个 windows phone 示例应用程序,其中我必须在 UI 上显示来自 SD 卡的图像。

为此,我做了一个小函数:

Private void UpdateImage()
{
    BitmapImage bitmapd = new BitmapImage(new Uri(D:\Pictures\img1.bmp));
    FingerImage.Source = bitmapd;
}

此图像 D:\Pictures\img1.bmp 文件正在被我的应用程序动态替换为另一个图像。所以 URI 保持不变,只有图像数据被更改。

我需要在 UI 上更新这个新图像 ,为此,我正在调用上面的函数。但是上面的函数并不是每次都更新UI上的图片,除了第一次。之后,图像在 UI 上保持不变。

我找到了问题的解决方案。我需要忽略现有的图像缓存。以下是工作代码:

    Private void UpdateImage()
    {
        BitmapImage bitmapd = new BitmapImage(new Uri(D:\Pictures\img1.bmp));
        bitmapd.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
        FingerImage.Source = bitmapd;
    }