我在应用程序中动态加载图像时遇到了一个大问题。当我启动应用程序时,占位符图像源为空。当我点击按钮时,会创建并加载一张图像作为占位符源。再次点击时,会创建新的图像,但旧的图像仍然显示。图像的创建完美无缺。我的磁盘上的文件是它们应该的文件。
以下函数设置图像占位符的源。
两个选项BitmapCacheOption和BitmapCreateOptions并没有改变任何东西。
有人能帮我吗?
以下函数设置图像占位符的源。
public void setImage(string path)
{
BitmapImage img = new BitmapImage();
img.BeginInit();
img.UriSource = new Uri(path, UriKind.Relative);
img.EndInit();
//Set Refreshing Options
img.CacheOption = BitmapCacheOption.None;
img.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
placeholder.Source = img;
}
两个选项BitmapCacheOption和BitmapCreateOptions并没有改变任何东西。
有人能帮我吗?