Change label behavior to support switching by clicking in WPF

Is there a way to change tag behavior to support click-through in WPF?

that is, the Selector.IsSelected property toggles between โ€œTrueโ€ and โ€œFalseโ€ with a click of a button?

Sincerely.

+3
wpf label wpf-controls toggle
source share
3 answers
 <StackPanel> <CheckBox IsChecked="{Binding IsChecked, ElementName=checkbox}" Content="Hello"> <CheckBox.Template> <ControlTemplate TargetType="CheckBox"> <ContentPresenter/> </ControlTemplate> </CheckBox.Template> </CheckBox> <CheckBox x:Name="checkbox" Content="A normal checkbox"/> </StackPanel> 

Please note that the above template does not change the appearance of the label depending on whether it was installed or not. It may be something you need - it's hard to say without additional information.

+8
source share

It is better to use Checkbox for this behavior and to your liking.

Remember that controls in WPF represent behavior that does not look.

+2
source share

Just add a simpler solution to mikelt21 in the duplicate message:

 <CheckBox> <Label Content="Your text here"/> </CheckBox> 
0
source share

All Articles