0
我的網格有很多行和列。我如何訪問gridIndex的內容
它看起來像這樣。
<Grid x:Name="grid" Grid.ColumnSpan="3" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Grid.RenderTransform>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<rectImg:RectImg Grid.Row="0" Grid.Column="0"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="1"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="2"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="3"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="4"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="5"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="6"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="7"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="8"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="9"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="9"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="9"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="9"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="10"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="11"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="12"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="13"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="14"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="0" Grid.Column="15"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="1" Grid.Column="0"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="2" Grid.Column="0"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="3" Grid.Column="0"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="4" Grid.Column="0"></rectImg:RectImg>
<rectImg:RectImg Grid.Row="5" Grid.Column="0"></rectImg:RectImg>
</Grid>
我想在初始化代碼後面使用的foreach或在此代碼:
<rectImg:RectImg Grid.Row="0" Grid.Column="0"></rectImg:RectImg>
我已經嘗試了很多方法。但我沒做到..很多人說「使用Grid.SetColumn和Grid.SetRow」,但它不能應用....
我該如何解決這個問題?
它的工作原理!謝謝!!!!!!!! –
很高興我能幫到你。 –