WPF Radiobutton (two) (binding to boolean value)

前端 未结 8 2029
深忆病人
深忆病人 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:36

    Simplified version of ragunathan's answer.

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) =>
        Convert(value);
    
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) =>
        Convert(value);
    
    private object Convert(object value) => 
        value is bool ? !(bool)value : value;
    

提交回复
热议问题