Notice in this demo that you can still 'select' a single row - independent of the checkboxes. I need to preserve that functionality. I just want to add checkboxes next to each item that can be checked (one or more). I also need to know how to get the checked items.
12 Answers, 1 is accepted
The ListBox for WPF doesn't provide built-in CheckBoxes functionality, but you could easily implement it by yourself. You will need to apply ItemTemplate which contains CheckBox and TextBlock for example which TextBlock will be bound to a property in the custom object from the ListBox ItemsSource collection. As for the CheckBoxes they can be bound to the IsSelected property of each ListBoxItem, so whenever you check a CheckBox the item gets selected. Finally in order to get the checked items you could just use the SelectedItems collection of the ListBox which will contain only the selected ones. For your convenience I have prepared and attached a sample project which demonstrates the exact approach.
Hope this helps.
I also attached a screenshot of the example showing how it allows you to select a single item, but CHECK multiple items.
I modified the sample project from the previous post in order to demonstrate the exact scenario from the mentioned example but for WPF. Only single item can be selected and when the button is clicked it gets all of the items which have checked CheckBoxes.
Hope this will work for you.
I modified the project in order to be runnable in VS 2010. Please try it the attached project and let me know if you still have any issues.
kalin, this was great! the demonstration project was simple and to the point, and easy to follow. It solved my users' requests.
kalin, thanks. your attached project was simple and to the point, and easy to follow. it solved the issue our users had requested in quite an elegant fashion
The RadListBox control does not provide a CheckBoxes property out of the box, however, as my colleague demonstrated, such a setup is not hard to accomplish.
Could you please clarify whether using an approach such as the one Kalin provided would work for you?
If that is not the case, feel free to open a new feature request in our feedback portal regarding such functionality and if the demand for such a feature is high, we will consider implementing it in future releases.