是否有可能具有2列的网格,并且每个网格具有不同的行数,例如第一列4列,第二列3列。
我想要图片上的东西
答案 0 :(得分:7)
您不能只用一个Grid
来做到这一点,而是使用多个Grid
控件,ColumnSpan
和RowSpan
属性以及某种控件,可以生成这样的“网格”。
<Window x:Class="SOWPF.MainWindow"
...
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Margin="4" Background="Orange"/>
<Border Grid.Column="0" Grid.Row="1" Margin="4" Background="Green"/>
<Border Grid.Column="0" Grid.Row="2" Margin="4" Background="Green"/>
<Border Grid.Column="0" Grid.Row="3" Margin="4" Background="Green"/>
<Border Grid.Column="0" Grid.Row="4" Margin="4" Background="Green"/>
<Border Grid.Column="1" Grid.Row="1" Grid.RowSpan="4" Margin="4" Background="Orchid">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Grid.Row="0" Margin="4" Background="DeepSkyBlue"/>
<Border Grid.Row="1" Margin="4" Background="DeepSkyBlue"/>
<Border Grid.Row="2" Margin="4" Background="DeepSkyBlue"/>
</Grid>
</Border>
</Grid>
</Window>
视图: