Image Control asynchronous

2019-08-13 06:27发布

I have an image control that I want it to load the image asynchronously over the network. I see some sample code in the network saying something like:

<Image HorizontalAlignment="Left" Height="118" Margin="2,8,0,0" VerticalAlignment="Top" Width="167" x:Name="ImageThumbnail" Source="{Binding SummaryImageLink, IsAsync=True}" />

However, in Windows Phone 7, I cannot find anything like that. Does anybody know a way to do that without I have to code a lot myself

3条回答
劫难
3楼-- · 2019-08-13 07:08

Unfortunately you are going to have to write, or include, more code yourself to do this properly. I have a similar solution with the goal to cache images after the first download. The image cache class is accessed via a IValueConverter, so once you have included the appropriate code, you only have to add a decorator on the Image object:

<Image Source="{Binding ElementName=ImageSource, Path=Text, Converter={StaticResource imageCacheConverter}}" Width="200" />

Full details here and source code here: http://www.ben.geek.nz/2010/07/one-time-cached-images-in-windows-phone-7/

查看更多
地球回转人心会变
4楼-- · 2019-08-13 07:10

Alternatively you can asynchronously download the picture (for ex. with a BackgroundWorker) and assign it as source for your image control only when the download has completed.

查看更多
登录 后发表回答