In the Silverlight API, there isn't any such thing as a
WrapPanel, which is a shame because the WrapPanel is such a useful control in
WPF. Fortunately, the Silverlight toolkit contains the WrapPanel control in
the System.Windows.Controls namespace. Whereas the StackPanel stacks elements
one on top of the other, WrapPanel will wrap content to the next line if need
be. Content that would normally be clipped gets shifted to the next line
automatically, growing the WrapPanel container. If you do not want content to
wrap, plan your design carefully to avoid this situation, or use a StackPanel
element.
The WrapPanel has the same design as the StackPanel; it's
straightforward and easy to use, not defining any attached properties to
manage. Listing 5 has an example of using a WrapPanel for a zip code
definition.
Listing 5: Setting up a WrapPanel
<Grid ..>
<TextBlock Grid.Row="5" Grid.Column="0" Text="Zip Code" />
<c:WrapPanel Grid.Row="5" Grid.Column="1">
<TextBox Name="ZIPMAIN" />
<TextBox Name="ZIPEXTENSION" />
</c:WrapPanel>
</Grid>
The WrapPanel renders the main and extension zip code
textboxes on the same line. If, for whatever reason, the panel needs to wrap
the contents because of a sizing issue, the WrapPanel may wrap the extension
TextBox element to the next line.