tags:

views:

24

answers:

1

How do I add buttons by a loop to grid??

A: 

You cannot add multiple items to a grid without creating columns or rows, so for the sake of simplicity I am going to assume you will add your buttons to a StackPanel object with your desired orientation.

foreach( ... )
{
     Button b = new Button();
     b.Height = 25;
     b.Width = 100;
     b.Content = "My Label";
     MyStackPanel.Children.Add(b); // Use MyStackPanel.Children.Clear() to clear out all items
}
enforge