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

Panels in Other Controls

Some controls may support defining a custom panel in its template.  For instance, the ListBox supports setting up the panel you'd like to use as the panel of choice for the ListBox.  To define the listbox template, use the following approach:

<ListBox>
      <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                  <c:WrapPanel />
            </ItemsPanelTemplate>
      </ListBox.ItemsPanel>
</ListBox>

The WrapPanel element replaces the default panel for the ListBox; this means each item uses the WrapPanel means for rendering list box items.  If the number of items overflows, the WrapPanel expands to encompass the maximum height of the elements within the row.

Note that you cannot necessarily access the panel being used to wrap the items in the ListBox.  As was recommended by another poster on the silverlight.net forums, the Loaded event for the ListBox passes the instance of the panel via the sender property.  This is the only way to access the underlying panel, if you desire to.  In most cases, you won't need to do so.


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-2024 ASPAlliance.com  |  Page Processed at 2024-05-18 1:33:39 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search