【问题标题】:Listbox inside the checkbox content - WPF复选框内容内的列表框 - WPF
【发布时间】:2013-10-04 18:20:13
【问题描述】:

我在复选框内容中有列表框。每当列表框中发生任何单击事件时,我都希望选中该复选框。但它没有检查的问题,只有点击文本块才会检查。有什么想法吗?

 <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>

【问题讨论】:

    标签: c# wpf xaml checkbox


    【解决方案1】:

    尝试从ListBox 关闭命中测试:

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

    【讨论】:

      【解决方案2】:

      您可以在 CHECKBOX 上订阅 PreviewMouseLeftButtonUp 事件并在后面的代码中查看。

      【讨论】:

        猜你喜欢
        • 2023-03-23
        • 2014-10-08
        • 1970-01-01
        • 1970-01-01
        • 2013-08-10
        • 1970-01-01
        • 2011-04-19
        • 1970-01-01
        相关资源
        最近更新 更多