Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 加载图像?_Windows Phone 7 - Fatal编程技术网

Windows phone 7 加载图像?

Windows phone 7 加载图像?,windows-phone-7,Windows Phone 7,我有一个列表框,需要在其中显示来自internet的图像 我有这样一个数据源: <DataTemplate x:Key="DataTemplate1"> <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <Image Source="{Binding image}"></Image>

我有一个列表框,需要在其中显示来自internet的图像

我有这样一个数据源:

<DataTemplate x:Key="DataTemplate1">
            <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                <Image Source="{Binding image}"></Image>
                <TextBlock Text="{Binding imagedec}"></TextBlock>
            </Grid>
        </DataTemplate>
我使用DataTemplate在listbox中绑定图像,如下所示:

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

我可以看到图像,但它来得很晚,在这种情况下显示图像的最佳方式是什么?

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

<Border Background="{StaticResource PhoneInactiveBrush}" Width="100" Height="100">
    <Image Source="{Binding image}" Stretch="UniformToFill" Width="100" Height="100" />
</Border>
只有当您可以设置固定的高度和宽度时,此解决方案才有效

更新

您应该使用LowProfileImageLoader来提高性能:

我知道,他们是从internet:D加载的,所以这是目前为止最好的解决方案?我们必须等待图像不显示或类似于异步数据/图像加载之类的操作,我不确定:如果设置映像,它将异步加载。您必须考虑到,在internat上加载图像可能需要一段时间。但也可以将图像加载到缓存本地存储并将图像绑定到此缓存。。。通过这种方式,您可以加载上一页中的图像,并在下一页中更快地显示。。。但是这个解决方案要花很多时间来实现。。。