开发者

Click on label to select radiobutton in WPF with MVVM

开发者 https://www.devze.com 2023-01-04 14:11 出处:网络
I\'m learning WPF, and am wondering if there\'s an idiomatic 开发者_如何学Pythonway to create a label that, when clicked, toggles a checkbox or radio button. I was somewhat surprised that the Target a

I'm learning WPF, and am wondering if there's an idiomatic 开发者_如何学Pythonway 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.)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消