mardi 11 décembre 2018

WPF Combobox with checkboxes inside

I have checkboxes inside of a Combobox and I want to click them:

If I click the Checkbox or the "Content" of the Checkbox it will check the Checkbox, but if I click on empty space right next to the "content", it will just select this Checkbox in the Combobox.

How can I prevent that? I want to check the box if I click on the whole field, not just on the text alone.

Here is my Code:

 <ComboBox Margin="2,2,2,0" ItemsSource="{Binding DataContext.AllTags, ElementName=self}" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <CheckBox IsChecked="{Binding IsChecked}" Content="{Binding Name}">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Checked">
                                            <i:InvokeCommandAction Command="{Binding DataContext.CmdCmx_UpdateTags, ElementName=self}" CommandParameter="{Binding}" />
                                        </i:EventTrigger>
                                        <i:EventTrigger EventName="Unchecked">
                                            <i:InvokeCommandAction Command="{Binding DataContext.CmdCmx_UpdateTags, ElementName=self}" CommandParameter="{Binding}"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </CheckBox>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="DropDownOpened">
                                <i:InvokeCommandAction Command="{Binding DataContext.CmdCmx_ClearTags, ElementName=self}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ComboBox>




Aucun commentaire:

Enregistrer un commentaire