jeudi 18 mars 2021

Clicking on non-text area inside checkbox fails to check item using WPF framework

I have a combobox control containing a list of checkboxes. The structure is as followed:

<ComboBox x:Name="cbxRH" HorizontalAlignment="Left" Margin="500.5,80,0,0" VerticalAlignment="Top" Width="126" IsEditable="True" IsTextSearchEnabled="True" StaysOpenOnEdit="True" TextBoxBase.TextChanged="cbxRH_TextChanged" Grid.Column="2">
    <ComboBox.ItemTemplate>
       <DataTemplate>
          <CheckBox x:Name="chkRH" IsChecked="{Binding checkStatus}" CommandParameter="{Binding index}" Checked="chk_Checked"  Unchecked="chk_Unchecked">
             <CheckBox.Content>
                <TextBlock Text="{Binding LO_Name_short}"/>
             </CheckBox.Content>
          </CheckBox>
       </DataTemplate>
     </ComboBox.ItemTemplate>
</ComboBox>

Now when I click the checkbox or the item text, I can select the item. But Only when I click the background(non-text area), nothing is selected and MyProject.BindClass appears in the textbox of combobox. MyProject is the project name and BindClass is the class whose properties are bund to the event shown above.

Is there a way that makes it possible that clicking on non-text area also enables to select items?




Aucun commentaire:

Enregistrer un commentaire