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

数据源:

效果:

每个数据和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属性上实现。

 

posted @ 2018-03-26 11:32  零基础刷书博客  阅读(1416)  评论(0编辑  收藏  举报