WPF 多个枚举标志到转换器参数?

WPF Multiple Enum Flags to Converter Parameter?

我有一个控件,如果枚举值为 (A | B | C),我需要它可见。

我知道如何使用转换器将控件的可见性绑定到单个枚举 (A)。

我该如何为这种情况做同样的事情?参数中会包含什么?

这是我使用的转换器:

public class EnumToVisibilityConverter : IValueConverter {
    public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
        if ( value == null || parameter == null || !( value is Enum ) )
            return Visibility.Hidden;
        string State = value.ToString( );
        string parameterString = parameter.ToString( );

        foreach ( string state in parameterString.Split( ',' ) ) {
            if ( State.Equals( state ) )
                return Visibility.Visible;
        }
        return Visibility.Hidden;
    }

    public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
        throw new NotImplementedException( );
    }
}

这是 XAML 绑定:

<UserControl.Visibility>
    <Binding
        Path="GameMode" Source="{x:Static S:Settings.Default}" Converter="{StaticResource ETVC}"
        ConverterParameter="{x:Static E:GameMode.AudiencePoll}" Mode="OneWay"/>
</UserControl.Visibility>

如何将 (A|B|C) 传递给转换器参数?是不是说{x:Static E:Enum.A | E:Enum.B | E:Enum.C}这么简单?

我找到了答案here

为大家省去一趟

<Binding Path="PathGoesHere" Source="{x:Static SourceGoesHere}" Converter="{StaticResource ConverterKeyGoesHere}">
    <Binding.ConverterParameter>
        <EnumTypeGoesHere>A,B,C</EnumTypeGoesHere>
    </Binding.ConverterParameter>
</Binding>

如前所述here语法应该是

<Binding Path="PathGoesHere" Source="{x:Static SourceGoesHere}" Converter="{StaticResource ConverterKeyGoesHere}">
    <Binding.ConverterParameter>
        A|B|C
    </Binding.ConverterParameter>
</Binding>

因为逗号分隔 XML 并且参数总是一个单一的枚举值。虽然没有智能感知