Set WPF Image Source From Hyperlink (From Internet)

I am trying to set the WPF image source from an internet link. How can i do this? I tried this but it does not work:

Image image1 = new Image(); BitmapImage bi3 = new BitmapImage(); bi3.BeginInit(); bi3.UriSource = new Uri("link" + textBox2.Text + ".png", UriKind.Relative); bi3.CacheOption = BitmapCacheOption.OnLoad; bi3.EndInit(); 
+4
source share
1 answer

Turning a "link" into a URL is certainly not true. Just make sure you enter the full path of the image in the text box.

 // For example, type the following address into your text box: textBox2.Text = "http://www.gravatar.com/avatar/ccac9a107581b343e832a2b040278b98?s=128&d=identicon&r=PG"; bi3.UriSource = new Uri(textBox2.Text, UriKind.RelativeOrAbsolute); 
+7
source

Source: https://habr.com/ru/post/1415813/


All Articles