WPF Control Layout - WrapPanel
(Page 3 of 5 )
WrapPanel is similar to StackPanel. The difference is that, whereas StackPanel puts each new control in a new row or column, WrapPanel keeps adding controls in the desired direction until there is no more space. Then, it puts the next control into a new row or column, “wrapping” it similar to the way text may be wrapped. Also, like StackPanel, WrapPanel has an Orientation property, except it defaults to Horizontal.
A WrapPanel confined to a width of 300 pixels will render eight buttons like this:

<WrapPanel>
<Button Content="Button 1" />
<Button Content="Button 2" />
<Button Content="Button 3" />
<Button Content="Button 4" />
<Button Content="Button 5" />
<Button Content="Button 6" />
<Button Content="Button 7" />
<Button Content="Button 8" />
</WrapPanel>
The above WrapPanel has a horizontal orientation (the default, remember), but switching the Orientation property to Vertical and confining the WrapPanel to a height of 100 pixels would render the same eight buttons differently:

<WrapPanel Orientation="Vertical">
...
</WrapPanel>
Next: DockPanel >>
More Windows Scripting Articles
More By Peyton McCullough