【WPF】设置ListBox容器子控件的布局
2017-01-21 10:05
295 查看
需求:像下图那样显示把一组内容装入ListBox中显示。要求用WrapPanel横向布局,顺序如图中的数字。
问题:ListBox默认的布局是从上往下单列的,所以需要设置布局。
实际使用中,还要给ListBox设置它的ItemsSource绑定到ViewModel中的某个列表,不会是向上面那样直接手打一串的TextBox的。
重要的参考:
http://www.cnblogs.com/qishichang/archive/2010/09/30/1839040.html
问题:ListBox默认的布局是从上往下单列的,所以需要设置布局。
<ListBox x:Name="HousePlansLB"> <ListBox.Template> <ControlTemplate TargetType="ListBox"> <WrapPanel Width="600" Orientation="Horizontal" IsItemsHost="True"/> </ControlTemplate> </ListBox.Template> <TextBox Text="测试" Width="140" Height="90" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Text="测试" Width="140" Height="90" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Text="测试" Width="140" Height="90" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Text="测试" Width="140" Height="90" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Text="测试" Width="140" Height="90" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Text="测试" Width="140" Height="90" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Text="测试" Width="140" Height="90" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> </ListBox>
实际使用中,还要给ListBox设置它的ItemsSource绑定到ViewModel中的某个列表,不会是向上面那样直接手打一串的TextBox的。
重要的参考:
http://www.cnblogs.com/qishichang/archive/2010/09/30/1839040.html
相关文章推荐
- WPF布局控件简单介绍
- 为什么像ComoBox,ListBox这类控件的SelectedIndex不能在可视化编程环境设置?
- wpf从我炫系列2----布局控件的使用(下)
- 跟着小王学wpf系列之 常用控件布局控件
- 无废话WPF系列7:WPF布局控件
- WPF中使用Style设置界面控件外观属性
- [WPF][UserControl] 之 热键设置控件(HotKeySettingControl)
- 、首先,我们添加一个主界面窗体,命名为MainForm,该窗体IsMdiContainer设置为True,也就是设置为多文档窗体格式。拖拉布局控件"WeifenLuo.WinFormsUI.Docking.DockPanel"到主窗体MainForm中,并
- 模拟了个FoxMail的账号属性设置 TZListBox 控件
- 让WPF的TextBox控件可以使用System.Windows.Forms.FontDialog设置样式
- WPF中的控件布局
- WPF中的布局控件
- WPF布局(2)-控件拖动
- wpf从我炫系列1----布局控件的使用(上)
- WPF布局控件AvalonDock介绍以及应用中遇到的一个问题
- WPF中的控件布局
- WPF中的控件布局
- DNN下布局用户控件以及设置页面跳转
- [WPF]为控件中的焦点设置样式以及 FocusVisualStyle
- WPF布局控件