我想在WrapPanel中显示一个图像列表。我如何才能做到这一点,或者我应该使用其他控件?
发布于 2011-11-24 22:13:31
您完全可以使用WrapPanel显示图像列表,可以垂直或水平滚动。要获得像People hub中那样的全景平铺效果,你可以这样做:
<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>
请注意,ListBox中的WrapPanel确实会提取您定义的DataTemplate。因此,您可以完全自由地将任何列表绑定到您的WrapPanel。
希望这能有所帮助!
发布于 2018-01-12 19:10:16
搜索同样的东西,发现了这个:Displaying a Collection of Items in a WrapPanel。
<ItemsControl ItemsSource="{Binding ActorList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Image}" Height="100"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
或者,您可以使用Xceed's SwitchPanel。
发布于 2011-11-24 14:36:47
是的,绝对不是WrapPanel,它没有ItemsSource,它不能接受列表。使用ListBox,您可以设置ItemsSource。
编辑
https://stackoverflow.com/questions/8258410
复制