Currently I have a ListBox that is wrapped horizontally, but I would like to switch this to the LongListSelector. The reason for this, other than that it may be populated with a lot of items, is that when using a ListBox there is no consistency with how the items are wrapped. I would like to see columns of three, with however many rows are required when the items are shown in the view, but with the ListBox this may either be two or three depending on the width of the item. The item contains both an image and text under it, and the text (when wider than the image) is causing the items in the list to wrap in a non uniform manner.
What I have currently is
<ListBox Name="ListBoxEffects" SelectionMode="Single" ItemsSource="{Binding}" Margin="{Binding}"
toolkit:TiltEffect.IsTiltEnabled="True" SelectionChanged="ListBox_SelectionChanged" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel ItemWidth="Auto" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Margin="12,0,0,24" >
<Image Source="{Binding Thumbnail}" Width="128" Height="128" />
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
And what I was trying to accomplish is
<phone:LongListSelector Name="ListBoxEffects" Margin="{Binding}"
toolkit:TiltEffect.IsTiltEnabled="True"
LayoutMode="Grid" GridCellSize="128,128"
SelectionChanged="ListBox_SelectionChanged" >
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Margin="12,0,0,24" >
<Image Source="{Binding Thumbnail}" Width="128" Height="128" />
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
I could just change <toolkit:WrapPanel ItemWidth="Auto" />
in the original to a specified width, but I believe in the long run with several items being added dynamically, the LongListSelector will be a much better option. As of now, there are no errors but nothing shows in the view.