Search code examples
wpfwpf-controls

ComboBox with Checkboxes on selective ComboBox Items


I have a ComboBox which takes it's values from ObservableCollection which gets it's data from a XML file. I am able to display the data from XML to the ComboBox whose code is :

<ComboBox x:Name="ComboBox1" ItemSource="{Binding Path = <Property Name>}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedItem, UpdateSourceTrigger=PropertyChanged}">

Now I want to make modifications such that only some Items in the ComboBox have a checkbox which will be based on the text of the ComboBox Item. If I use Data Template in ComboBox.ItemTemplate, then all the items of combobox will have the checkbox which I don't want.

Is there any way I can achieve this?


Solution

  • In the ItemTemplate, use the DataTemplate in which there will be triggers that change the Visibility of the flag according to the conditions you need.