This is a migrated thread and some comments may be shown as answers.

WPF Listbox with checkboxes

12 Answers 2122 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 21 Feb 2014, 08:58 PM
I would like to create a listbox that contains checkboxes similar to this, but for WPF:

http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/checkboxes/defaultcs.aspx

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.

Thank you,
James DiEdwardo

12 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 24 Feb 2014, 03:07 PM
Hi James,

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. 

Regards,
Kalin
Telerik
0
James
Top achievements
Rank 1
answered on 24 Feb 2014, 09:32 PM
Thanks for the reply, however what I need is a ListBox that allows users to SELECT a single item at time.  But then I also want to add a checkbox next to each item that allows multiple items to be CHECKED (and a way to detect which ones are checked).   Just like in this example (but I need a WPF version):  http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/checkboxes/defaultcs.aspx

I also attached a screenshot of the example showing how it allows you to select a single item, but CHECK multiple items.

0
Kalin
Telerik team
answered on 25 Feb 2014, 02:36 PM
Hello James,

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.

Regards,
Kalin
Telerik
0
James
Top achievements
Rank 1
answered on 25 Feb 2014, 07:22 PM
Thank you!  It appears that this is a VS 2013 project... would it be convenient for you to output as 2010?
0
Kalin
Telerik team
answered on 26 Feb 2014, 12:33 PM
Hi James,

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.

Regards,
Kalin
Telerik
0
James
Top achievements
Rank 1
answered on 26 Feb 2014, 02:02 PM
I think you may have forgotten to attach?
0
Kalin
Telerik team
answered on 26 Feb 2014, 03:54 PM
Hello James,

I'm sorry about that - please check my previous post again for the attached sample project.

Regards,
Kalin
Telerik
0
Nir
Top achievements
Rank 1
answered on 11 May 2014, 03:26 PM
Thank you very much, that was very helpful :)
0
Stephen
Top achievements
Rank 1
Iron
answered on 14 May 2015, 11:16 PM

kalin, this was great! the demonstration project was simple and to the point, and easy to follow. It solved my users' requests.

thanks!

0
Stephen
Top achievements
Rank 1
Iron
answered on 14 May 2015, 11:18 PM

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

thanks!

stephen

0
JeffSM
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 22 Aug 2018, 09:22 PM
We are in 2018! ListView already provide a CheckBox?
0
Dilyan Traykov
Telerik team
answered on 23 Aug 2018, 12:44 PM
Hello JeffSM,

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.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListBox
Asked by
James
Top achievements
Rank 1
Answers by
Kalin
Telerik team
James
Top achievements
Rank 1
Nir
Top achievements
Rank 1
Stephen
Top achievements
Rank 1
Iron
JeffSM
Top achievements
Rank 2
Iron
Veteran
Iron
Dilyan Traykov
Telerik team
Share this question
or