C# 在wpf中重新加载图像

C# 在wpf中重新加载图像,c#,wpf,bitmapimage,C#,Wpf,Bitmapimage,我正在尝试重新加载我在WPF中显示的图像(System.Windows.Controls.image)。我将源代码设置为: ScreenAtco01Image.Source = new BitmapImage(new Uri(@"Y:/screenshots/naratco08-0-0-screenshot.png", UriKind.RelativeOrAbsolute)); 我做了一个按钮,它应该强制重新加载这个图像(它在磁盘上每秒钟改变一次) 我已尝试重置源,但没有任何作用。但是,如果我

我正在尝试重新加载我在WPF中显示的图像(System.Windows.Controls.image)。我将源代码设置为:

ScreenAtco01Image.Source = new BitmapImage(new Uri(@"Y:/screenshots/naratco08-0-0-screenshot.png", UriKind.RelativeOrAbsolute));
我做了一个按钮,它应该强制重新加载这个图像(它在磁盘上每秒钟改变一次)

我已尝试重置源,但没有任何作用。但是,如果我将源更改为不同的图像,则会加载此不同的图像。好像有什么事发生了


谢谢你的帮助。

找到了一个适合我的答案:

BitmapImage _image = new BitmapImage();
_image.BeginInit();
_image.CacheOption = BitmapCacheOption.None;
_image.UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
_image.CacheOption = BitmapCacheOption.OnLoad;
_image.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
_image.UriSource = new Uri(@"Y:/screenshots/naratco08-0-0-screenshot.png", UriKind.RelativeOrAbsolute);
_image.EndInit();
ScreenAtco01Image.Source = _image;

谢谢!我自己也为此奋斗了一段时间,这就成功了。如果可以的话,我会投更多的票。