mercredi 7 juillet 2021

ComboBox without selection item. Only popup checkboxes

I have a comboBox. When opened it shows checkboxes.

Problem: While checking/unchecking one becomes selected item for my comboBox. I don't want that.

  • I want to disable selectable item, because logic is done when checking/unchecking items in comboBox's popup.
  • And preferably default text "-- Select flags --".

enter image description here

enter image description here

enter image description here

I tried:

  • IsReadOnly property does not exist. Cannot be selected. Maybe its due to my ItemTemplate because its not - TextBox (I don't know).
  • IsEditable="False" does not work
  • IsHitTestVisible, IsEnabled="False" make it unopenable. I cannot get to check boxes
            <ComboBox Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top" 
                Name="flagComboBox" IsTextSearchEnabled="True" Margin="0,10,0,0"
                IsEditable="False" Text="-- Select flags -- (does not show)"
                >
                <ComboBox.ItemTemplate>
                    <DataTemplate >
                        <CheckBox Name="checkFileException"
                            Checked="Check_Flag" Unchecked="Uncheck_Flag" 
                            Content="{Binding}" 
                            CommandParameter="{Binding}"
                            >
                        </CheckBox>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>




Aucun commentaire:

Enregistrer un commentaire