Reputation: 3
I am trying to make a visible image array in C# for windows phone 7. I do:
Image[] stone = new Image[100];
public Game() //constructor
{
InitializeComponent();
stone[0] = new Image();
BitmapImage bi = new BitmapImage();
bi.SetSource(Application.GetResourceStream(new Uri(@"notselected.png", UriKind.Relative)).Stream);
stone[0].Source = bi;
stone[0].Width = 200;
stone[0].Height = 200;
stone[0].Opacity = 1.0;
}
It compiles, but it doesn't show the image. What should I do?
Upvotes: 0
Views: 1197
Reputation: 124722
Well, you have a bunch of images in memory, but this stuff isn't magic; the runtime doesn't just assume that you want these images displayed and then also assume how to display them.
You will have to add the images to some control which displays its children. You can use a grid, a ListView populated with an ImageList, whatever.
Upvotes: 1
Reputation: 20764
You have to add the images to a control in your page, eg a grid or stackpanel:
MyGrid.Children.Add(stone[0]);
Upvotes: 1