WPF
1. Grid
<Grid>
<Grid.RowDefinitions>
<RowDefinition/> //行
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/> //列
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Background="#f26321" Grid.Row="0" Grid.Column="0" Margin="10"/>
<Border Background="#8CC43D" Grid.Row="0" Grid.Column="1" Margin="10"/>
<Border Background="#00abed" Grid.Row="1" Grid.Column="0" Margin="10"/>
<Border Background="#efb70b" Grid.Row="1" Grid.Column="1" Margin="10"/>
// 分别是背景颜色,二维数组编号,边距
</Grid>
2. Panel
a. StackPanel
<StackPanel Orientation="Horizontal"> //默认竖直方向 orientation改变方向
<Button Width="200" Height="80" HorizontalAlignment="Center" Background="Yellow"/>
<Button Width="200" Height="80" HorizontalAlignment="Center" Background="Red"/>
<Button Width="200" Height="80" HorizontalAlignment="Center" Background="Blue"/>
<Button Width="200" Height="80" HorizontalAlignment="Center" Background="Green"/>
<Button Width="200" Height="80" HorizontalAlignment="Center" Background="Black"/>
//长 宽 水平位置 颜色
</StackPanel>
//复杂文本
<Button Width="200" Height="100">
<Button.Content>
<StackPanel Orientation="Horizontal" >
<TextBlock Text="❤"/>
<TextBlock Text="欢迎光临"/>
</StackPanel>
</Button.Content>
</Button>
b. WarpPanel
- 和StackPanel类似,在有限的容器范围内可以自动换行,如果窗口缩小时会自动换
c.DockPanel
<DockPanel>
<Button DockPanel.Dock="Top" Width="100" Height="50"/>
<Button DockPanel.Dock