我尝试从一个Internet连接设置WPF图像源。 我怎样才能做到这一点? 我想这一点,但不工作:
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();
在前面加上"link"
的网址是肯定不正确。 只要确保您键入图像的完整路径到您的文本框中。
// 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);