Advertisement
Guest User

Untitled

a guest
Sep 8th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  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;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement