BrianKE
BrianKE

Reputation: 4185

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?

Upvotes: 1

Views: 1133

Answers (1)

grek40
grek40

Reputation: 13458

You could place the text in a separate TextBlock and wrap them together in a 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>

Upvotes: 2

Related Questions