Wrapped Listbox items in Silverlight and WPF

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">
            <usrcntrl:Image ImageName="{Binding Name}" ServerPath="{Binding ServerPath}" />
            <controls:WrapPanel />

I have also disabled the horizontal scroll bar so the images wrap to the next line.

Posted on by Joe in Silverlight, WCF

Add a Comment