2
// Create the image element.
Image simpleImage = new Image();    
simpleImage.Width = 100;
simpleImage.Margin = new Thickness(5);

// Create source.
BitmapImage bi = new BitmapImage();

simpleImage の Source を bi に設定するにはどうすればよいですか?

4

2 に答える 2

2
// Create the image element.
Image simpleImage = new Image();    
simpleImage.Width = 200;
simpleImage.Margin = new Thickness(5);

// Create source.
BitmapImage bi = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block.
bi.BeginInit();
bi.UriSource = new Uri(@"/Images/1.jpg",UriKind.RelativeOrAbsolute);

bi.EndInit();
// Set the image source.
simpleImage.Source = bi;
于 2013-10-09T08:52:54.060 に答える
2
var uri = new Uri(@"C:\Users\Public\Pictures\Sample Pictures\Koala.jpg");
var bi = new BitmapImage(uri);
simpleImage.Source = bi;
于 2013-10-09T09:02:27.207 に答える