容器<Grid></Grid>介绍
window中的<Grid> 创建两行
<RowDefinitions Height ="auto"/> //"auto"自适应按钮的最大尺寸 以最大尺寸定义的。 绝对尺寸"100" "2*"上面一行的尺寸是下面一行的2倍
<RowDefinitions/>
<Grid.RowDefinitions>
创建两列
<ColumnDefinitions/>
<ColumnDefinitions/>
<Grid.ColumnDefinitions>
添加按钮
<Button width="100" Height="50"/>
//<Button width="100" Height="100"/>
填充颜色
<Bordor background="Red"/>
<Bordor Grid.Row="1" background="Yellow"/>
<Bordor Grid.Cloumn="1" background="Blue"/>
<Bordor Grid.Row="1" Grid.Cloumn="1" background="Green"/>
RowDefinitions / ColumnDefinitions 用于给Grid分配行与列。
ColumnSpan / RowSpan 则用于设置空间元素的跨列与阔行。
<Bordor background="Red" Grid.ColumnSpan ="2"/> //Grid.ColumnSpan ="2"占据两列空间 Grid. RowSpan ="2"占据两行空间
容器<StackPanel></StackPanel>介绍
StackPanel主要用于垂直或水平排列元素、在容器的可用尺寸内放置有限个元素,元素的尺寸总和(长/高)不允许超过StackPanel的尺寸, 否则超出的部分不可见。
水平或垂直排列元素、Orientation属性分别: Horizontal / Vertical
<StackPanel Orientation="Horizontal"> // 按钮水平排列
<StackPanel>
<Button width="100" Height="50"/> //默认从上往下排列
<Button width="100" Height="50"/>
<Button width="100" Height="50"/>
<Button width="100" Height="50"/>
<Button width="100" Height="50"/>
</StackPanel>
容器<WrapPanel></WrapPanel>介绍
WrapPanel默认排列方向与StackPanel相反、WrapPanel的Orientation默认为Horizontal。WrapPanel具备StackPanel的功能基础上具备在尺寸变更后自动适应容器的宽高进行换行换列处理。
水平或垂直排列元素、针对剩余空间不足会进行换行或换列进行排列 <WrapPanel Grid.row="1"Orientation=" Horizontal">
<WrapPanel Grid.row="1" Orientation=" Horizontal">
<Button width="100" Height="50"/> //默认水平排列
<Button width="100" Height="50"/>
<Button width="100" Height="50"/>
<Button width="100" Height="50"/>
<Button width="100" Height="50"/>
</WrapPanel>
容器<DockPanel></DockPanel>介绍
根据容器的边界、元素进行Dock.Top、Left、Right、Bottom设置。
默认DockPanel中的元素具备DockPanel.Dock属性, 该属性为枚举具备: Top、Left、Right、Bottom。 默认情况下, DockPanel中的元素不添加DockPanel.Dock属性, 则系统则会默认添加 Left。
DockPanel有一个LastChildFill属性, 该属性默认为true, 该属性作