Thursday, January 12, 2012

Loading Image from External URL (http://...)



void LoadImage()
{
 string img = "http://localhost/Mycode/Images/HirenLogo.png";
 WebClient webClientImgDownloader = new WebClient();
            webClientImgDownloader.OpenReadCompleted            

            += new OpenReadCompletedEventHandler(webClientImgDownloader_OpenReadCompleted);
            webClientImgDownloader.OpenReadAsync(new Uri(img, UriKind.Absolute));
 
}
void webClientImgDownloader_OpenReadCompleted(object sender,
            OpenReadCompletedEventArgs e)  
{
            BitmapImage bitmap = new BitmapImage();
            bitmap.SetSource(e.Result);
            ImgHeaderLogo.Source = bitmap;


No comments:

Post a Comment