J’ai défini ColumnDefinitions
dans XAML comme:
...
Dans le code derrière, StackPanel
un StackPanel
tant qu’enfants dans MainGrid
comme:
MainGrid.Children.Add(stackPanel);
Comment placer ce stackPanel dans la première colonne du code, comme nous le faisons dans XAML comme: Grid.Column="0"
ou Grid.ColumnSpan="2"
ou Grid.Row="1"
, etc.
Vous pouvez utiliser les SetRow
, SetColumn
, SetColumnSpan
:
Grid.Children.Add(stackPanel); Grid.SetRow(stackPanel, 1); Grid.SetColumn(stackPanel, 0); Grid.SetColumnSpan(stackPanel, 2);