Posted by Joe | Posted in Silverlight, WCF | Posted on 02-06-2009
I wanted to display a list of image thumbnails similar to how Windows Explorer does it so they are displayed horizontally and wrap onto the next line. The ListBox allows you to choose a template for the panel used to display items. The following XAML uses the WrapPanel for the ItemsPanelTemplate and gives the functionality I wanted.
<listBox x:Name="ImageList" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<listBox.ItemTemplate>
<dataTemplate>
<usrcntrl:Image ImageName="{Binding Name}" ServerPath="{Binding ServerPath}" />
</dataTemplate>
</listBox.ItemTemplate>
<listBox.ItemsPanel>
<itemsPanelTemplate>
<controls:WrapPanel />
</itemsPanelTemplate>
</listBox.ItemsPanel>
</listBox>
I have also disabled the horizontal scroll bar so the images wrap to the next line.


