WPF ListBox CheckBox 里面如何添加字段进行显示
<Grid DockPanel.Dock="Top" Height="300">
<DockPanel>
<Grid DockPanel.Dock="Left" Width="3600" Margin="180,0,0,0">
<ListBox x:Name="LtBxTestCases" Width="150" Height="250" HorizontalAlignment="Left" VerticalAlignment="Top" ItemContainerStyle="{StaticResource listviewStyle}" SelectionChanged="LtBxTestCases_SelectionChanged" >
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected}" Style="{StaticResource CheckBoxStyle2}" Content="{Binding Name}" CommandParameter="{Binding No}" Cursor="Hand" Click="CheckBox_Click" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Center" ScrollViewer.HorizontalScrollBarVisibility="Auto" UseLayoutRounding="False" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</DockPanel>
</Grid>
键值对 的数据如何绑定 到listbox 可以通过 Listbox进行绑定值
list集合里面的Model
public class Info
{
public string No { get; set; }
public string Name { get; set; }
}
绑定Combox里面的值
完成效果图