tags:

views:

129

answers:

1

I have a ListBox bound to an observable collection.

I also have a data pager bound to the itemsource of the list box.

I currently have the data pager set to only show up to 3 rows.

How would I go about changing the style ListBox style (or something else) such that I could have a 3X3 display? For example, the first three items in my observable collection would be displayed on the first row of the list box, horizontally next to each other, then the next row would contain the next three items in the observable collection?

Any info would be greatly appreciated.

Thanks.

Chris

+1  A: 

It sounds like you want to use an ItemsControl with a WrapPanel (from the Silverlight Toolkit) in the ItemsPanelTemplate.

    <ItemsControl xmlns:controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <controls:WrapPanel/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
    </ItemsControl>

Here's a short tutorial about the WrapPanel: http://blogs.silverlight.net/blogs/justinangel/archive/2008/11/05/silverlight-toolkit-wrappanel.aspx

Gabe
That would solve the problem of displaying 3 list items next to each other horizontally - but essentially what I was is a 3 x 3 setup - where the can be 3 items across horizontally and 3 items down vertically - displaying a total of 9 list items.
Chris
A `StackPanel` would just show items horizontally or vertically, but a `WrapPanel` would wrap at the end of each row or column to show all 9 items.
Gabe
You are correct - thank you!
Chris