How to get selected items from listbox has checkboxes in WPF?
问题 This is the ListBox code: <ListBox x:Name="courseslistview" ItemsSource="{Binding .}" FontSize="18.667" FontFamily="Trebuchet MS" LayoutUpdated="courseslistview_LayoutUpdated"> <ListBox.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding .}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> How can I use C# to get all the checked checkboxes in the above ListBox? 回答1: It would probably be best to bind the CheckBox to the IsSelected property of the ListBoxItem , like so: <DataTemplate>