正在加载图片?

时间:2012-05-06 20:40:34

标签: windows-phone-7

我有列表框,我需要从互联网上显示图像

我有这样的数据源:

enter image description here

我使用DataTemplate将“图像”绑定在列表框中,如下所示:

<DataTemplate x:Key="DataTemplate1">
            <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                <Image Source="{Binding image}"></Image>
                <TextBlock Text="{Binding imagedec}"></TextBlock>
            </Grid>
        </DataTemplate>

我能够看到图像但是来得太晚了,在这种情况下显示图像的最佳方式是什么?

1 个答案:

答案 0 :(得分:0)

这是因为必须首先从互联网(或缓存)加载图像。尝试添加灰色背景作为占位符并设置固定的高度和宽度:

<Border Background="{StaticResource PhoneInactiveBrush}" Width="100" Height="100">
    <Image Source="{Binding image}" Stretch="UniformToFill" Width="100" Height="100" />
</Border>

此解决方案仅在您可以设置固定的高度和宽度时才有效...

更新

您应该使用LowProfileImageLoader来提高效果: http://blogs.msdn.com/b/delay/archive/2010/09/02/keep-a-low-profile-lowprofileimageloader-helps-the-windows-phone-7-ui-thread-stay-responsive-by-loading-images-in-the-background.aspx