Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Click on label to select radiobutton in WPF with MVVM

I'm learning WPF, and am wondering if there's an idiomatic way to create a label that, when clicked, toggles a checkbox or radio button. I was somewhat surprised that the Target attribute on Label doesn't do this. I am using the MVVM pattern (with the MVVMFoundation framework.)

like image 699
davidtbernal Avatar asked Jan 24 '26 03:01

davidtbernal


1 Answers

The target property sets the focus to the target element when the labels pre-defined access key is pressed so does not do what you want.

Off the top of my head I would suggest creating a button and using a Style to make it look like a label. You can add 'content' to a checkbox though and this will check the box when clicked.

like image 147
Leom Burke Avatar answered Jan 25 '26 18:01

Leom Burke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!