Reputation: 1436
I'm looking to create a grid of buttons to make a simple game in Windows Phone just to test out what I can do with it.
I did the exact same thing with visual C#:
for (int j = 0; j < down; j++)
{
for (int i = 0; i < right; i++)
{
Button b = new Button();
b.SetBounds(i * 50, j * 50 + 30, 50, 50);
b.Click += new EventHandler(b_Click);
bArray[i, j] = b;
Controls.Add(b);
}
}
I was looking to recreate this in Windows Phone, but I can't seem to figure out how. If I do the same thing, but do say 'myGrid.Children.Add(b)', it seems to just place a single button in the center, even when I specify the top and left margins.
If anyone familiar with Silverlight and could tell me how I would translate the code I did in visual C# to Silverlight, i'd appreciate it.
Upvotes: 0
Views: 549
Reputation: 1091
Add to your Grid
a WrapPanel
from Silverlight for Windows Phone 7 Toolkit and add yours buttons to this WrapPanel
Upvotes: 1