WPF实现竖向排列并换行显示

时间:2018-03-26 12:39:16   收藏:0   阅读:1156

数据源:

技术分享图片

效果:

每个数据和TextBox绑定

技术分享图片

 

实现:

使用ItemsControl,设置ItemsPanel标签,数据类型是ItemsPanelTemplate。

控制ItemsControl的条目容器为WrapPanel,Orientation="Vertical",可以竖向排列。

分别定义ItemsControl和TextBox的Height,则实现竖向排列后换行。

技术分享图片

注意:

ItemsSource为int[]或者List<int>时,无法绑定TextBox。

需要将int[]或者List<int>转换为List<Class>,Class带有int ShowProperty属性,再将TextBox绑定到ShowProperty属性上实现。

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!