从Hyper Link(来自Internet)设置WPF图像源

我尝试从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(); 

在URL之前加上"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);