WPF Radiobutton (two) (binding to boolean value)

前端 未结 8 2022
深忆病人
深忆病人 2020-12-24 10:51

I have a property of type boolean presented with checkbox.

I want to change that to two radiobuttons that bind on the same property presenting the value true/false.<

8条回答
  •  青春惊慌失措
    2020-12-24 11:43

    You can achieve this without a converter if you set the GroupName property of two radio button to the same value (so only one can be checked at the time). Then, set IsChecked of one radio button to "True", and bind IsChecked of another to your Boolean. Switching radio buttons will change the Boolean value, however, changing the Boolean value to False will not check the other radio button.

    Thanks, Vlad

提交回复
热议问题