界面操作为:
<ListBox Name="ListBoxMain" Grid.ColumnSpan="2" Grid.Row="1" Grid.Column="1" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel HorizontalAlignment="Left" /> <!--加入panel-->
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate> <!--绑定数据是另一个模板-->
<DataTemplate>
<CheckBox Content="{Binding ChengyuText}" IsChecked="{Binding Checked ,Mode=TwoWay}" Click="CheckBox_Click"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
参考如下:
https://www.yisu.com/jc/865833.html
另外注意:两者差别
Template模板之DataTemplate和ControlTemplate
https://www.jianshu.com/p/8e0e1d190d30