How to create a CheckedListBox in WPF

WPF doesn’t have a CheckedListBox control by default but with the WPF being so flexible it’s simple to make one just by changing the ItemsTemplate of a ListBox.

Suppose we have a Customers class like so:

public class Customer
    public string Name { get; set; }

And we would like to display this with a CheckBox beside it in a list. To hold the value of the CheckBox you will need a wrapper class. Here is a generic one that works well for this:

using System.ComponentModel;

namespace Jarloo
    public class CheckedListItem<T> : INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;

        private bool isChecked;
        private T item;

        public CheckedListItem()

        public CheckedListItem(T item, bool isChecked=false)
            this.item = item;
            this.isChecked = isChecked;

        public T Item
            get { return item; }
                item = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Item"));

        public bool IsChecked
            get { return isChecked; }
                isChecked = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("IsChecked"));

This class makes it easy to keep track of which items are checked and since it’s generic it doesn’t matter what object it wraps.

Here is the code behind we will need:

using System.Collections.ObjectModel;
using System.Windows;

namespace Jarloo
    public partial class MainWindow : Window
        public ObservableCollection<CheckedListItem<Customer>> Customers { get; set; }

        public MainWindow()

            Customers = new ObservableCollection<CheckedListItem<Customer>>();
            Customers.Add(new CheckedListItem<Customer>(new Customer(){Name="Kelly Smith"}));
            Customers.Add(new CheckedListItem<Customer>(new Customer(){Name="Joe Brown"}));
            Customers.Add(new CheckedListItem<Customer>(new Customer(){Name="Herb Dean"}));
            Customers.Add(new CheckedListItem<Customer>(new Customer(){Name="John Paul"}));

            DataContext = this;

As you can see it’s just an ObservableCollection of CheckListItems that wrap a Customer. The rest of the code is just building a few dummy records.

And the XAML is simple too:

<Window x:Class="Jarloo.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <ListBox ItemsSource="{Binding Customers}" >
                    <CheckBox IsChecked="{Binding IsChecked}" Content="{Binding Path=Item.Name}" /> 

Notice we just set the ListBox ItemsSource property to our ObservableCollection, then we define an ItemsTemplate that will be used for
each item. The template contains our CheckBox, with the IsChecked property bound to the CheckListItem’s IsChecked property, and the
Content bound to our Customer class. Note that since Customer is in the CheckListItem’s Item property we need to reference the customer name as Item.Name.

Keep in mind you can use that CheckedListItem class to wrap any object, it’s a handy little class to keep around.

Categories:   Code

Tags:  , , , ,


  • Posted: October 26, 2011 14:56

    Joe C

    Works great - just what I was looking for - thanks for posting the code.
  • Posted: February 21, 2012 03:53


    Thank's it's clear and easy to reuse. Helps a lot.
  • Posted: August 6, 2013 04:55


    Thanks, simple and good :)
  • Posted: October 23, 2013 06:15


    Thanks a lot, this article is simple and easy to understand
  • Posted: January 31, 2014 16:08


    Hello, thanks for your code, I need to run the app with all the checkboxes actives, what can I do?
  • Posted: February 20, 2014 05:14


    Thanks a lot, i was looking the same. but in my case i want to group the checkbox item, is there any way to group it. want to show country and its state, user can able to select the state. ei.g. i want to show as below, where state will have checkbox count 1 state1 state2 count 2 state 1 state 2 Thanks, -R
  • Posted: April 13, 2014 07:09


    Great! Straight to the point.
  • Posted: September 26, 2014 12:23


    How do you populate Customers = new ObservableCollection<CheckedListItem>(); from a linq query?
  • Posted: May 5, 2015 11:35


    Thanks so much for this Kelly! I am having trouble with my implementation of this solution, where my checkbox Content is showing blank. Owing to the age of this thread I doubt you are monitoring it, but if you are and feel inclined to respond, here is a link to my question on Stackoverflow: http://stackoverflow.com/questions/30058445/wpf-listbox-with-checkbox-data-template-binding-content-property-of-checkbox-n
    • Posted: May 5, 2015 20:38

      Kelly Elias

      Looks like someone on stackoverflow beat me to it! But thanks for reading and I'm happy you found the content here useful.
      • Posted: May 6, 2015 14:03


        Thanks for the response Kelly! I still don't understand why my underlying Charge class has to implement INotifyPropertyChanged when your Customer class above doesn't, but implementing it certainly fixed my issue.
      • Posted: May 6, 2015 21:07

        Kelly Elias

        Actually the problem is mine. That Customer class should have implemented it. (you found a bug). The only reason I get away with it is because I set the customers in the constructor before they are bound. If you change the customer afterwards it will NOT work. Sorry this caused you problems, I'll have to update this article so others don't run into the same issue.
  • Posted: June 12, 2015 08:13


    Hello Kelly, Great article. I appreciate your time and effort. I have a little issue. I implemented the SelectionChanged event because I will need the the index and Item Name: private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = listbox1.SelectedIndex; string testName = ((CheckedListItem)listbox1.SelectedValue).Item.Name; } Everything works until I change the listbox's SelectionMode to "Multiple". The selectedIndex or the SelectedItem does not change after the first checked box. Something is not getting updated. Is there something else I need to implement? Thank you in advance!!!
  • Posted: August 12, 2015 07:51


    Hello Kelly, great article. I use this code in my application, I have 4 ListBoxes populated with a CheckedListItem-Collection. How can I determine in which ListBox the item was checked/unchecked? Or how can I force the ListBox to fire the SelectionChanged-Event depending on the CheckedListItem-PropertyChanged-Event (if the check-state changed)?
    • Posted: August 19, 2015 11:23

      Kelly Elias

      I'm not sure if you use MVVM but if so you can just bind the event you want to the viewmodel. The class supports INotifyPropeertyChanged.
  • Posted: May 7, 2016 05:51


    nice its really working