[英]Set WPF Image Source from a Hyper Link (from Internet)
I try to set WPF image source from an Internet link. 我尝试从Internet链接设置WPF图像源。 How can I do this?
我怎样才能做到这一点? I tried this, but doesn't 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();
Prepending "link"
to the URL is certainly incorrect. 在URL之前加上
"link"
肯定是不正确的。 Just make sure that you type the full path of your image into your textbox. 只需确保在文本框中键入图像的完整路径即可。
// 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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.