Examining Various Silverlight Containers
page 4 of 8
by Brian Mains
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 39495/ 93

WrapPanel

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.


View Entire Article

User Comments

Title: Microsoft.Windows.Controls   
Name: Evgen
Date: 2010-08-26 4:42:38 AM
Comment:
May be
Microsoft.Windows.Controls
instead of
System.Windows.Controls
?
Title: Silverlight   
Name: Prabhakar
Date: 2009-07-15 7:51:36 AM
Comment:
This is article very useful. I have query "Can we add a xmal file inside any panel/etc.." I want to display all my xaml files/controls to display in one page. Please advice me if it is possible.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-06-19 7:10:22 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search