Introduction
This blogs describes how to create a Combobox that contains Checkbox in the item
using WPF XML. use the below xmal codes to create the combobx that contains
check boxes.
XML Code
<ComboBox
HorizontalAlignment="Left"
Margin="120,537,0,0"
VerticalAlignment="Top"
Width="120"
Name="cmb">
<ComboBox.ItemTemplate>
<DataTemplate>
<CheckBox
Name="ckabc"
Content="{Binding
Name}" Checked="ckabc_Checked_1"></CheckBox>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Write following below C# code to get select the combobox item
C# Code
private
void ckabc_Checked_1(object
sender, RoutedEventArgs e)
{
CheckBox cb = (CheckBox)sender;
ContentPresenter CP = (ContentPresenter)cb.TemplatedParent;
string S = CP.TemplatedParent.ToString();
ComboBoxItem CBI = (ComboBoxItem)CP.TemplatedParent;
CBI.IsSelected = (bool)cb.IsChecked;
}