4

インターネット リンクから 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();
4

1 に答える 1

7

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);
于 2012-06-03T11:44:27.253 に答える