开发者

Array of buttons WP7

开发者 https://www.devze.com 2023-04-11 21:04 出处:网络
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\

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 Buttons 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.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号