0
在我的應用我想動態創建一個網格佈局,但沒有得到預期的輸出網格佈局:如何創建動態的XAML
下面是我試過的代碼:
Grid LayoutGrid = new Grid();
//Created Two Columns
ColumnDefinition gridCol1 = new ColumnDefinition();
ColumnDefinition gridCol2 = new ColumnDefinition();
LayoutGrid.ColumnDefinitions.Add(gridCol1);
LayoutGrid.ColumnDefinitions.Add(gridCol2);
Grid Col1Grid = new Grid();
//Create Two Rows
RowDefinition gridRow1 = new RowDefinition();
RowDefinition gridRow2 = new RowDefinition();
Col1Grid.RowDefinitions.Add(gridRow1);
Col1Grid.RowDefinitions.Add(gridRow2);
Grid.SetColumn(Col1Grid, 1);
return LayoutGrid;
佈局我想創建是這樣的:
的就是你得到的輸出? – derpirscher
我只得到兩列,第1列沒有創建行。 – Dishant
您未將Col1Grid添加到您的LayoutGrid中 – derpirscher