简体   繁体   English

WPF:将复选框的可点击区域限制为仅复选框

[英]WPF: Limit clickable area of checkbox to the checkbox only

I am using a checkbox as follows: 我正在使用如下复选框:

<CheckBox Content="Reload Code Table Rules"
          IsChecked="{Binding ReloadCodeTableRules, UpdateSourceTrigger=PropertyChanged}"
          VerticalAlignment="Center" />

Currently the checked state will change if I click on either the checkbox or the label. 当前,如果我单击复选框或标签,则选中状态将更改。 Is it possible to limit this to only change when the checkbox is checked? 是否可以将其限制为仅在选中复选框时才更改?

You could place the text in a separate TextBlock and wrap them together in a StackPanel : 您可以将文本放在单独的TextBlock然后将它们包装在StackPanel

<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
    <CheckBox IsChecked="{Binding ReloadCodeTableRules, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/>
    <TextBlock Margin="4,0,0,0" Text="Reload Code Table Rules" VerticalAlignment="Center"/>
</StackPanel>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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