Array of buttons WP7
I want to add an array of buttons created in the code of my apps to the UI. It'll be a kind of a grid of but开发者_运维知识库tons. How can i do it in Windows Phone? I tried different ways but i didn't make it. Thanks
Create a StackPanel
(or Grid
or some other panel type that can layout your controls according to your specification).
Create all you buttons (you can put them in a List<Button>
to keep track of them) and add each button to StackPanel.Children
.
Edit
If you put your Button
s in a Grid
and want to put each Button
in a separate column you need to set the attached property Grid.Column
Button b = new Button();
grid.Children.Add(b);
b.SetValue(Grid.ColumnProperty, 1); // 1 is column 1, etc.
精彩评论