首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将WrapPanel项来源设置为list?

如何将WrapPanel项来源设置为list?
EN

Stack Overflow用户
提问于 2011-11-24 22:13:06
回答 3查看 14.3K关注 0票数 14

我想在WrapPanel中显示一个图像列表。我如何才能做到这一点,或者我应该使用其他控件?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-11-25 06:13:31

您完全可以使用WrapPanel显示图像列表,可以垂直或水平滚动。要获得像People hub中那样的全景平铺效果,你可以这样做:

代码语言:javascript
运行
复制
       <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。

希望这能有所帮助!

票数 28
EN

Stack Overflow用户

发布于 2018-01-13 03:10:16

搜索同样的东西,发现了这个:Displaying a Collection of Items in a WrapPanel

代码语言:javascript
运行
复制
<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

票数 11
EN

Stack Overflow用户

发布于 2011-11-24 22:36:47

是的,绝对不是WrapPanel,它没有ItemsSource,它不能接受列表。使用ListBox,您可以设置ItemsSource。

编辑

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8258410

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档