本帖最后由 WENZISUN 于 2013-12-21 15:15 编辑
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
for (int i = 0; i < 10; i++)
{
ColumnDefinition colDef = new ColumnDefinition();
grid.ColumnDefinitions.Add(colDef);
}
for (int i = 0; i < 10; i++)
{
Button btn = new Button();
btn.Content = i;
Grid.SetColumn(btn, i);
grid.Children.Add(btn);
}
}
疑问是,循环创建多个button,可是对象名都是btn,这我有些想不明白 |