2011-11-24 69 views

回答

20

您可以完全使用WrapPanel来显示图像的列表,水平或垂直滚动​​。为了得到那种全景瓷砖效果就像在与您的图像人民枢纽,你可以做这样的事情:

 <controls:PanoramaItem Header="something" Orientation="Horizontal" Margin="0,-15,0,0" >     
      <ListBox Name="SomeList" Margin="0,0,-12,0" ItemsSource="{Binding SomeItemsList}" > 
       <ListBox.ItemsPanel> 
        <ItemsPanelTemplate> 
         <toolkit:WrapPanel x:Name="wrapPanel" Width="700" /> 
        </ItemsPanelTemplate> 
       </ListBox.ItemsPanel> 
       <ListBox.ItemTemplate> 
        <DataTemplate> 
         <StackPanel Orientation="Horizontal" Margin="0,0,0,17">         
          <Image Height="200" Width="200" Margin="12,0,9,0" Source="{Binding ImageURL}" />         
         </StackPanel> 
        </DataTemplate> 
       </ListBox.ItemTemplate> 
      </ListBox> 
     </controls:PanoramaItem> 

请注意,列表框内部的WrapPanel不会拿起你定义的DataTemplate ..所以你有完全自由将任何列表绑定到您的WrapPanel。

希望这会有所帮助!

+0

非常感谢。 –

+3

而不是ListBox,你可以使用更简单的ItemsControl。 – Heiner

2

是的definetly不是WrapPanel,它没有ItemsSource,它不能拿一个列表。 使用列表框,您可以设置ItemsSource。

编辑

enter image description here

+0

我知道ListBox,但它不能很好地显示照片。 ItemSource是例子,我想说,我给WrapPanel一个列表,它会自动显示这些列表。 –

+0

那么你可以玩ListBox的ControlTemplate来显示你想要的。 WrapPanel从Panel继承。你基本上需要一些实现ItemsControl的东西。查看我的答案,查看实现ItemsControl的元素以获取您的选择。 – MBen

+0

好的谢谢。(15个字符) –

0

搜索相同的东西,并发现这个问题:Displaying a Collection of Items in a WrapPanel

<ItemsControl ItemsSource="{Binding ActorList}" Margin="20"> 
<ItemsControl.ItemTemplate> 
    <DataTemplate> 
     <Image Source="{Binding Image}" Height="100"/> 
    </DataTemplate> 
</ItemsControl.ItemTemplate> 
<ItemsControl.ItemsPanel> 
    <ItemsPanelTemplate> 
     <WrapPanel/> 
    </ItemsPanelTemplate> 
</ItemsControl.ItemsPanel> 

,或者您可以使用Xceed's SwitchPanel

相关问题