WrapPanel将子元素自左向右逐个地排列, 若一个水平行中放不下,就排在下一行。面板的方向可以是水平或垂直的
<Window x:Class="Panel布局.WrapPanelxaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="WrapPanelxaml" Height="300" Width="367"> <WrapPanel> <Button Width="100" Height="30" Margin="5">ButtonA</Button> <Button Width="100" Height="30" Margin="5">ButtonB</Button> <Button Width="100" Height="30" Margin="5">ButtonC</Button> <Button Width="100" Height="30" Margin="5">ButtonD</Button> <Button Width="100" Height="30" Margin="5">ButtonE</Button> <Button Width="100" Height="30" Margin="5">ButtonF</Button> <Button Width="100" Height="30" Margin="5">ButtonG</Button> <Button Width="100" Height="30" Margin="5">Buttonh</Button> </WrapPanel> </Window>