在我的XAML,我有:Web客戶端負載JPG和GIF到圖像
<Image Height="150" HorizontalAlignment="Left" Margin="0,4,0,0" Name="imgLogo" Stretch="Fill" VerticalAlignment="Top" Width="417" />
<Image Height="343" HorizontalAlignment="Left" Margin="0,155,0,0" Name="imgPhoto" Stretch="Fill" VerticalAlignment="Top" Width="417" />
在後面的C#代碼,我有:
WebClient wcForLogo = new WebClient();
wcForLogo.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wcForLogo_DownloadStringCompleted);
wcForLogo.DownloadStringAsync(new Uri("http://mySite/logo.gif"));
WebClient wcForPhoto = new WebClient();
wcForPhoto.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wcForPhoto_DownloadStringCompleted);
wcForPhoto.DownloadStringAsync(new Uri("http://mySite/photo.jpg"));
但現在我不知道怎麼抓圖像並將其張貼在我創建的XAML控件中。
2個問題:
- 有沒有辦法給e.Result直接複製到圖片控件,或者我應該緩存圖像,並使用緩存爲源,或者我應該保存圖像隔離存儲,然後將其用作源,然後在完成後刪除圖像?無論哪種情況,你能告訴我如何用代碼?
- GIF和JPG的處理方式有何不同?如果是這樣,你能告訴我兩種不同的方式嗎?
非常感謝鏈接!事實證明,這是最好的答案,因爲我不確定圖像會以什麼圖像格式出現,所以我遵循其中一篇博客文章的建議,而您的鏈接建議使用瀏覽器控件。 – 2012-04-24 11:35:02