首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何自定义ListBox的ItemsPanelTemplate布局?

如何自定义ListBox的ItemsPanelTemplate布局?
EN

Stack Overflow用户
提问于 2012-07-11 15:49:21
回答 1查看 1.5K关注 0票数 0

我想为我的ListBox指定多个列,但是我的googling技巧在这一点上失败了。

如何修改ItemsPanelTemplateListBox以自定义所显示的列?

编辑:忘了把我已经试过的东西

我试过了密码

代码语言:javascript
复制
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
        <UniformGrid Columns="3" />
    </ItemsPanelTemplate>

除了我失去了垂直滚动条外,这是可行的。

EN

回答 1

Stack Overflow用户

发布于 2012-07-11 19:14:03

这里是一个简单的例子,我认为您正在寻找,有3列,项目包装,和自动垂直滚动将根据周围的布局工作。

代码语言:javascript
复制
<ListBox HorizontalContentAlignment="Stretch">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <UniformGrid Columns="3"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Border MinHeight="150" Margin="5" Background="Green" CornerRadius="4">
                <TextBlock Text="{Binding}" Foreground="White"/>
            </Border>
        </DataTemplate>
    </ListBox.ItemTemplate>

    <System:String>One</System:String>
    <System:String>Two</System:String>
    <System:String>Three</System:String>
    <System:String>Four</System:String>
    <System:String>Five</System:String>
    <System:String>Six</System:String>
    <System:String>Seven</System:String>
    <System:String>Eight</System:String>
    <System:String>Nine</System:String>
    <System:String>Ten</System:String>
</ListBox>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11436499

复制
相关文章

相似问题

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