我得到了下面的代碼,試圖從網絡加載圖像到一個圖像控件,當我運行它時,我得到一個錯誤在給定的行,沒有網絡訪問被允許:Silverlight Windows Phone 7:從URL加載圖片
private void button1_Click(object sender, RoutedEventArgs e)
{
WebClient webClientImgDownloader = new WebClient();
webClientImgDownloader.OpenReadCompleted += new OpenReadCompletedEventHandler(webClientImgDownloader_OpenReadCompleted);
webClientImgDownloader.OpenReadAsync(new Uri("http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/80000/5000/100/85108/85108.strip.print.gif", UriKind.Absolute));
}
void webClientImgDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(e.Result); // ERROR HERE!
image1.Source = bitmap;
}
的Silverlight爲Windows Phone 7
問題已解決。 Silverlight不支持GIF,因此我寫了一個將GIF轉換爲JPG的小頁面:www.lenniedevilliers.net/displaygif.aspx?link=http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/ 80000/5000/100/85108/85108.strip.print.gif – 2010-03-16 15:24:05