预览一张图片,同时从 url windows phone 8 请求另一张图片

preview an image while requesting another one from url windows phone 8

我需要预览默认图像,同时从 url 获取我的确切图像 这是我获取图像的代码

Uri uri = new Uri(myUrl);
            Profile.Source = new BitmapImage(uri);

"Profile"是预览请求图片的Image

您可以使用两张图片。第一个将是您想要的占位符,第二个将是稍后显示的个人资料图片并覆盖第一个。

您需要将这些图片放在同一个地方,一张在另一张上面。您可以使用 Grid 来实现。

<Grid>
    <Image x:Name="Placeholder" Source="/Assets/Placeholder.png" />
    <Image x:Name="Profile" ImageOpened="Profile_ImageOpened" />
</Grid>

Placeholder.png是已添加到项目中的图像。

现在,我们想知道何时下载个人资料图片。事件 ImageOpened 为我们指明了方向。当个人资料图片完全下载时,我们可以使用它来隐藏占位符。

private void Profile_ImageOpened(object sender, RoutedEventArgs e)
{
    Placeholder.Visibility = Visibility.Collapsed;
}