#400 – 使用ItemsPanel 属性将WrapPanel 作为ListBox的显示面板(Using a WrapPanel as the Items Panel for a ListBox)
来源:互联网 发布:武神赵子龙网络点击率 编辑:程序博客网 时间:2024/06/08 01:32
ListBox 的ItemsPanel 属性可以指定定义显示各子项的面板的模板。你可以通过定义自己的模板重写ListBox 常见的垂直堆叠式布局。
如果你设置了ItemsPanel 模板为WrapPanel,ListBox 将会有WrapPanel的特性。
在下面的例子中,我们将上一篇中的ListBox 稍作修改。指定ItemsPanel 包含一个WrapPanel。
<Grid> <ListBox ItemsSource="{Binding MovieList}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <Image Source="{Binding Image}" Stretch="None"/> <Label Content="{Binding TitleWithYear}"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel IsItemsHost="True" Orientation="Horizontal" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> </Grid>
可以看到,将ItemsPanel 设置为WrapPanel后,改变窗口的大小,ListBox显示会自动根据窗口大小换行。
原文地址:https://wpf.2000things.com/2011/10/04/400-using-a-wrappanel-as-the-items-panel-for-a-listbox/
0 0
- #400 – 使用ItemsPanel 属性将WrapPanel 作为ListBox的显示面板(Using a WrapPanel as the Items Panel for a ListBox)
- WPF中ListBox的WrapPanel布局
- 基于modern ui for wpf的在线公开课平台 之四 ListBox+WrapPanel实现平铺效果
- WrapPanel
- WrapPanel面板布局
- Incremental Searching for a ListBox
- #424 – 使ListBox 中每一项保持一致大小(Getting Data-Bound Items in a ListBox to Be a Consistent Size)
- WrapPanel的使用和动画效果
- 以前的笔记或摘录:Get Listbox Items from a TWebBrowser Document?
- #379 – 将ToolTip当做放大器使用(Using a Tooltip As a Magnifier)
- #395 – 通过数据绑定丰富ListBox 的内容(Rich ListBox Content using Data Binding)
- 有关WrapPanel组件的研究
- 将类的实例作为ListBox中的一项输出
- WPF-使用面板控制内容布局,比较Canvas,WrapPanel,StackPanel,Grid,ScrollViewer
- WPF-使用面板控制内容布局,比较Canvas,WrapPanel,StackPanel,Grid,ScrollViewer
- easyui中的panel(面板)的属性href的使用
- (转载)mfc listbox 控件-ListBox控件的使用
- (转载)mfc listbox 控件-ListBox控件的使用
- Docker实用指南:将Python Web应用容器化
- ios开发-数据库网络之php的登陆和注册(7)
- java 双链表,没有循环
- HBuilder连接夜神android模拟器
- linux 乱码文件重命名
- #400 – 使用ItemsPanel 属性将WrapPanel 作为ListBox的显示面板(Using a WrapPanel as the Items Panel for a ListBox)
- 判断List、Map、Set是否为空及效率比较
- python3 从基础入门到高级进阶练习题之----基础篇004
- Eclipse 中Logcat只显示level解决方法
- 在windows上编译Android静态库
- Java 中Sleep 用法
- 微信号开通检测软件
- ionic实现轮播图效果
- mysql根据身份证查询年龄,地址,性别