2011-04-25 67 views
0

嗨,大家好,我創造,我感到使用堆疊面板和電網布局控制格式化成像數據的形式適當的佈局在運行時將控制一個Silverlight項目。電網兒童指數

在情況我在運行時添加網格列之一,像一些列後,以前它有3列,現在我的第二個指數增加2個列,還更新了其他指標的。直到這一切都好。 但是當我得到格子的孩子像第一排。我將1,4,5,2,3作爲孩子的索引。 我想讓他們爲1 2 3 4 5

回答

1

嘗試使用Insert方法而不是修改索引。例如:

<Grid x:Name="DataGrid"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 
    <StackPanel Orientation="Horizontal"> 
     <TextBlock Text="LastName" VerticalAlignment="Center"/> 
     <TextBox /> 
    </StackPanel> 
</Grid> 

然後在代碼:

// Insert the first name StackPanel before the existing last name panel 
DataGrid.Children.Insert(0, firstNameStackPanel);