Tag: 网格项目

我怎样才能dynamic地添加一个RowParameters到GridPanelTemplate?

我有一个固定数量的列和未知数量的行的网格。 行数在构造函数中设置一次。 <ItemsControl Name="myItemsControl" ItemsSource="{Binding Cells}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid Name="myGrid"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <!– some rows should be added here –> </Grid.RowDefinitions> </Grid> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemContainerStyle> <Style…/> </ItemsControl.ItemContainerStyle> </ItemsControl> 我已经尝试了下面这行代码,但是它返回null: object obj = myItemsControl.Template.FindName("myGrid", myItemsControl); 我怎样才能在代码中添加行到“myGrid”?