Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 8th, 2013  |  syntax: None  |  size: 0.97 KB  |  views: 75  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. string Image = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/187738_100000230436565_1427264428_q.jpg";
  2.        
  3. <Image Name="img" HorizontalAlignment="Left" VerticalAlignment="Top" Width="66" Height="66" Source="{Binding Image} " />
  4.        
  5. var bitmapImage = new BitmapImage();
  6. bitmapImage.BeginInit();
  7. bitmapImage.UriSource = new Uri("https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/187738_100000230436565_1427264428_q.jpg");;
  8. bitmapImage.EndInit();
  9.  
  10. img.Source = bitmapImage;
  11.        
  12. var imgUrl = new Uri("https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/187738_100000230436565_1427264428_q.jpg");
  13. var imageData = new WebClient().DownloadData(imgUrl);
  14.  
  15. // or you can download it Async won't block your UI
  16. // var imageData = await new WebClient().DownloadDataTaskAsync(imgUrl);
  17.  
  18. var bitmapImage = new BitmapImage {CacheOption = BitmapCacheOption.OnLoad};
  19. bitmapImage.BeginInit();
  20. bitmapImage.StreamSource = new MemoryStream(imageData);
  21. bitmapImage.EndInit();
  22.  
  23. return bitmapImage;