2011-10-31 75 views
0

我需要按照以下格式创建列表框;多列列表框

[x] [x] ^
[x] [x] | 
[x] [x] | ----> this is a side scroll and the [x] are pictures 
[x] [x] | 

我该怎么办?这是我的代码现在。

 <controls:PanoramaItem Header="New one" Name="Pan1" > 
       <ListBox Margin="0,0,-12,0" x:Name="NewTitlesListBox" 
         ItemsSource="{Binding NewPicturesLocal}" 
         SelectionChanged="NewListBoxSelectionChanged"> 

        <ListBox.ItemTemplate> 
         <DataTemplate> 
          <StackPanel Orientation="Horizontal" Margin="0,0,0,20"> 
    <Image Width="110" CacheMode="BitmapCache" Source="{Binding ThumbURL}" 
            Margin="12,0,9,0"/> 

          </StackPanel> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 
       </ListBox> 
      </controls:PanoramaItem> 

这样做的结果是:

[x] ^
[x] | 
[x] | ----> this is a side scroll and the [x] are pictures 
[x] | 

我试图用网格做到这一点(添加更多的列)与数据模板,但没有找到解决方案。

回答

2

一个简单的解决方案是使用Silverlight工具包中的WrapPanel: WrapPanel for WP7。你将不得不将你的ListBox的ItemsPanelTemplate设置为使用WrapPanel。在我链接的页面的评论中有一个例子。

4

从Silverlight工具包使用WrapPanel会解决我的问题

 <controls:PanoramaItem Header="New one" Name="Pan1" > 
       <ListBox Margin="0,0,-12,0" x:Name="NewTitlesListBox" 
         ItemsSource="{Binding NewPicturesLocal}" 
         SelectionChanged="NewListBoxSelectionChanged"> 

       <ListBox.ItemsPanel> 
       <ItemsPanelTemplate> 
        <toolkit:WrapPanel /> 
       </ItemsPanelTemplate> 
       </ListBox.ItemsPanel> 

        <ListBox.ItemTemplate> 
         <DataTemplate> 
          <StackPanel Orientation="Horizontal" Margin="0,0,0,20"> 
    <Image Width="110" CacheMode="BitmapCache" Source="{Binding ThumbURL}" 
            Margin="12,0,9,0"/> 

          </StackPanel> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 
       </ListBox> 
      </controls:PanoramaItem> 
+0

很高兴你发布你的解决方案。我相信这对其他人来说会很方便。 – Danexxtone