简体   繁体   中英

Listbox inside the checkbox content - WPF

I have listbox inside the checkbox content. I want the checkbox to be checked whenever any click event happen in the listbox. But the problem it does not check, only clicking on the textblock does check. Any ideas how ?

 <CheckBox Checked="orderItemChecked" 
                          Unchecked="orderItemUnchecked" 
                          Grid.Column="0" Grid.Row="0" IsChecked="{Binding Path=Completed}"
                          HorizontalContentAlignment="Stretch" >
                    <StackPanel>
                        <TextBlock Text="{Binding Path=sItemName}" ></TextBlock>
                        <ListBox Grid.Row="1" HorizontalAlignment="Left" HorizontalContentAlignment="Stretch"
                                ItemsSource="{Binding Path=aSinglOptns}"
                                Margin="20,0,0,0"
                                ItemTemplate="{StaticResource SinglOptnTmpl}"
                                Style="{StaticResource SheetListStyle}"
                                ItemContainerStyle="{StaticResource ListBoxItemStyle}"/>

                    </StackPanel>
                </CheckBox>

尝试从ListBox关闭命中测试:

<ListBox Grid.Row="1" IsHitTestVisible="false" ... />

您可以在CHECKBOX上订阅事件PreviewMouseLeftButtonUp,并在后面的代码中对其进行检查。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM