WPF中的脱机映像缓存 [英] Offline Image Cache in WPF
问题描述
我有一个WPF应用程序,其中 从URL加载图片 当有互联网连接&
应从缓存中加载这些图像  ;每当没有活跃的互联网连接时。
我的 问题 是 - 图像未被缓存以显示在后续应用程序启动中
没有任何活动的互联网连接。
我搜索了几个小时,并尝试了几乎所有可能的组合 CreateOptions
& CacheOption
,
,但结果有问题。
XAML代码是这样的:
<图片
宽度=" {Binding FOOD_TILE_W}" MaxWidth =" 380"
Height =" {Binding FOOD_TILE_H} " MaxHeight =" 240"
Stretch =" UniformToFill">
< Image.CacheMode>
< BitmapCache EnableClearType =" False"
RenderAtScale =" 1"
SnapsToDevicePixels =" False" />
< /Image.CacheMode>
< Image.Source>
< ; BitmapImage UriSource =" {Binding ImageUrl}"
CreateOptions =" IgnoreImageCache"
CacheOption =" OnLoad" />
< /Image.Source>
< / Image>
除了"绑定"代码之外,没有其他C#代码。
是否有可能要实现我的目标?如果是,请怎么样?
嗨Touhid,
BitmapImage
自动
默认缓存远程图像。最好与CreateOptions =" BackgroundCreation"
for
the best performance。< Image Height =" 100" Width =" ; 100" Margin =" 12,0,9,0">
< Image.Source>
< BitmapImage UriSource =" {Binding ImgURL}" CreateOptions =" BackgroundCreation" />
< /Image.Source>
< / Image>更详细的信息,请看一下:
https://stackoverflow.com/questions/17261114/image-source -and-caching / 17278222
最好的问候,
樱桃跨度>
I have a WPF app, which loads images from URL when there's internet connection & should load those images from cache whenever there's no active internet connection.
My problem is - images are not being cached to show in subsequent app-launches without any active internet connection.
I have searched for hours & tried almost all possible combinations of CreateOptions
& CacheOption
,
but with the same problematic result.
The XAML code is like this:
<Image Width="{Binding FOOD_TILE_W}" MaxWidth="380" Height="{Binding FOOD_TILE_H}" MaxHeight="240" Stretch="UniformToFill"> <Image.CacheMode> <BitmapCache EnableClearType="False" RenderAtScale="1" SnapsToDevicePixels="False" /> </Image.CacheMode> <Image.Source> <BitmapImage UriSource="{Binding ImageUrl}" CreateOptions="IgnoreImageCache" CacheOption="OnLoad"/> </Image.Source> </Image>
There's no more C# code, except the `Binding` codes of course.
Is it possible to achieve what I am trying? If yes, please how?
Hi Touhid,
BitmapImage
automatically caches remote images by default. It's best used in conjunction withCreateOptions="BackgroundCreation"
for the best performance.<Image Height="100" Width="100" Margin="12,0,9,0"> <Image.Source> <BitmapImage UriSource="{Binding ImgURL}" CreateOptions="BackgroundCreation"/> </Image.Source> </Image>More detailed info, please take a look:
https://stackoverflow.com/questions/17261114/image-source-and-caching/17278222
Best Regards,
Cherry
这篇关于WPF中的脱机映像缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!