c# – 重新加载图像在wpf
发布时间:2020-12-15 04:01:59 所属栏目:百科 来源:网络整理
导读:我正在尝试重新加载一个图像(System. Windows.Controls.Image)我在WPF中显示.我设置的源码是这样的: ScreenAtco01Image.Source = new BitmapImage(new Uri(@"Y:/screenshots/naratco08-0-0-screenshot.png",UriKind.RelativeOrAbsolute)); 我做了一个按钮,
我正在尝试重新加载一个图像(System.
Windows.Controls.Image)我在WPF中显示.我设置的源码是这样的:
ScreenAtco01Image.Source = new BitmapImage(new Uri(@"Y:/screenshots/naratco08-0-0-screenshot.png",UriKind.RelativeOrAbsolute)); 我做了一个按钮,这应该强制重新加载这个图像(它每秒在磁盘上更改). 我已经尝试重新设置源代码,但是没有做任何事情.但是,如果我将Source更改为不同的图像,那么这个不同的图像将被加载.看起来有些东西是蜜蜂缓存的吗? 感谢您的帮助 解决方法
找到一个适合我的答案:
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; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |