Odd behavior when trying to change a bound RadioButton in WPF

后端 未结 1 1870
故里飘歌
故里飘歌 2021-01-23 22:08

I\'ve bound two radio buttons in my Child window to an Enum in my ViewModel which is constructed in the Main window. The binding works as

1条回答
  •  花落未央
    2021-01-23 22:24

    EDIT What about converting the enum to bool as follows?

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (parameter == null || !(bool)value)
            return DependencyProperty.UnsetValue;
        var parameterEnum = parameter as Enum;
    
        return parameterEnum;
    }
    

    0 讨论(0)
提交回复
热议问题