我有一个包含列定义和行定义的网格。我添加了一个比它应该测量的方块更大的用户控件。我试图设置一个5x5的网格与25个用户控件,让它们不溢出,并能够适应不同的台式机或笔记本电脑大小,而不会看起来很奇怪。 方块应该是相同的大小,相同的高度....
<Grid Margin="104,0,0,76" HorizontalAlignment="Left" Width="940" Height="864" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<local:ucteclarapida Grid.Row="0" Grid.Column="0" ></local:ucteclarapida>
<local:ucteclarapida Grid.Row="0" Grid.Column="1" > </local:ucteclarapida>
</Grid>
谢谢
答案 0 :(得分:0)
您可以使用 Viewbox 打包网格,并设置网格所需的宽度和高度。
<Viewbox VerticalAlignment="Bottom">
<Grid Width="940" Height="864">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<local:ucteclarapida Grid.Row="0" Grid.Column="0"/>
<local:ucteclarapida Grid.Row="0" Grid.Column="1"/>
</Grid>
</Viewbox>