Search code examples
silverlightsilverlight-4.0silverlight-toolkitwrappanel

Listbox with Wrappanel won't show elements


I'm quite perplexed as to why when I drop in a WrapPanel for my Silverlight 4 ListBox ItemsPanel, nothing shows up. If I only comment out the ItemsPanel, I get a normal vertical list of my little pictures with text. I added the background color to the WrapPanel just to convince myself the WrapPanel was actually there. I assume I'm missing something boneheaded, what is it?

    <ListBox Grid.Row="1" Grid.Column="1"
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             MinHeight="24"
             >
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Border> <StackPanel> <Image> <TextBlock> </StackPanel> </Border> (pseudo template)
            </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <toolkit:WrapPanel Background="Orange" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>

Solution

  • I've clueless as to why, but switching to an ObservableCollection for my ItemsSource did the trick. No clue why things would behave differently for the default ItemsPanel than a diff't panel, but it did.

    Thanks for looking into this.