Creating CheckListBox using XAML in WPF

Introduce
 
To create CheckListBox in WPF Using XAML you need to follow bellow steps:

Steps

  1. Add a listbox control in to your window
  2. Declare templet panel of your list box and add wrap panel in to the template panel, like bellow code
     

      <ListBox.ItemsPanel>

            <ItemsPanelTemplate>

                <WrapPanel IsItemsHost="True" Orientation="Vertical"/>

            </ItemsPanelTemplate>

      </ListBox.ItemsPanel>
     

  3. Add the Data Template into the Item Template of list box and add check box control in to the Data Template, Bind the date to the display with content of TextBox, see the code bellow:
     

    <ListBox.ItemTemplate> 

     <DataTemplate>

     <CheckBox Width="150" Foreground="Black" IsChecked="{Binding Active}" Content="{Binding Path=Name}"/>

     </DataTemplate>

     </ListBox.ItemTemplate>
     

  4. Code bellow is create the Check List box
     

       <ListBox HorizontalAlignment="Left" Height="242" VerticalAlignment="Top" Width="497" Margin="0,44,0,0" ScrollViewer.VerticalScrollBarVisibility="Disabled" x:Name="StudentList">

                <ListBox.ItemsPanel>

                    <ItemsPanelTemplate>

                        <WrapPanel IsItemsHost="True" Orientation="Vertical"/>

                    </ItemsPanelTemplate>

                </ListBox.ItemsPanel>

                <ListBox.ItemTemplate>

                    <DataTemplate>

                        <CheckBox Width="150" Foreground="Black" IsChecked="{Binding Active}" Content="{Binding Path=Name}"/>

                    </DataTemplate>

                </ListBox.ItemTemplate>

            </ListBox>