为什么 BitmapImage RequestCachePolicy 被忽略?
我发现在 BitmapImage
上设置 RequestCachePolicy
属性对于 Image
的 Source 时如何下载位图没有影响
设置为 BitmapImage
的此实例。
例如,如果我将 RequestCachePolicy
设置为 CacheOnly
,我希望不会发生任何互联网流量 - 指定的图像只能从缓存中检索。但相反,我看到向服务器发出下载图像的请求:
source = new BitmapImage(bmi.UriSource,
new RequestCachePolicy(RequestCacheLevel.CacheOnly));
// An image gets downloaded!
如果我在 HttpWebRequest
上设置静态 DefaultCachePolicy
属性,那么我的应用程序行为会以我想要的方式发生变化。会期望。即当它设置为CacheOnly
时,不会发生网络流量。
为什么 BitmapImage
上的 RequestCachePolicy
属性没有达到我预期的效果?
I'm finding that setting the RequestCachePolicy
property on BitmapImage
has no effect on how the bitmap is downloaded when an Image
's Source
is set to this instance of BitmapImage
.
For example, if I set the RequestCachePolicy
to CacheOnly
, I would expect no internet traffic to occur whatsoever - the specified image should only be retrieved from the cache. But instead, I see a request being made to the server to download an image:
source = new BitmapImage(bmi.UriSource,
new RequestCachePolicy(RequestCacheLevel.CacheOnly));
// An image gets downloaded!
If I set the static DefaultCachePolicy
property on HttpWebRequest
, then my application behaviour changes in a way I would expect. ie when it's set to CacheOnly
, no network traffic occurs.
Why is the RequestCachePolicy
property on BitmapImage
not having the effect I expect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 MSDN 站点: http://msdn.microsoft.com/en-us/library/system.net.cache.requestcachepolicy%28v=vs.110%29.aspx
According to the MSDN site: http://msdn.microsoft.com/en-us/library/system.net.cache.requestcachepolicy%28v=vs.110%29.aspx