1

我正在从 URL 设置图像源,但它不能正确显示图像,我在 windows phone 8 中使用的代码如下,在此先感谢..

 image1.Source =  new BitmapImage(new Uri("http://d3sdoylwcs36el.cloudfront.net/VEN-virtual-enterprise-network-business-opportunities-small-fish_id799929_size485.jpg",UriKind.Absolute));

结果是 在此处输入图像描述

4

1 回答 1

2

我做到了,为图像调用网络服务..代码如下..

WebClient webClient = new WebClient();
webClient.OpenReadCompleted += ImageOpenReadCompleted;
webClient.OpenReadAsync(new Uri("http://d3sdoylwcs36el.cloudfront.net/VEN-virtual-enterprise-network-business-opportunities-small-fish_id799929_size485.jpg"));




private void ImageOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
     if (!e.Cancelled && e.Error == null)
    {
        BitmapImage bmp = new BitmapImage();
        bmp.SetSource(e.Result);
        image1.Source = bmp;
    }
}

完成了 ... :)

于 2013-07-16T17:21:52.693 回答