1

我正在使用转换器

 <Window.Resources>
    <BooleanToVisibilityConverter x:Key="convVisibility"/>
</Window.Resources>

我有 3 个单选按钮:

    <RadioButton Content="PRE" GroupName="Env" Height="16" HorizontalAlignment="Left" Margin="492,167,0,0" Name="radioButton4" VerticalAlignment="Top" />
    <RadioButton Content="POST" GroupName="Env" Height="16" HorizontalAlignment="Left" Margin="558,167,0,0" Name="radioButton5" VerticalAlignment="Top" />
    <RadioButton Content="BOTH" GroupName="Env"  Height="16" HorizontalAlignment="Left" Margin="632,167,0,0" Name="radioButton6" VerticalAlignment="Top" />

如果选择了radioButton4 或radioButton6,我将尝试显示一个标签。目前可以使用它与 4 一起使用。

   <Label Content="PRE" Visibility="{Binding IsChecked, ElementName=radioButton4, Converter={StaticResource convVisibility}}" Height="28" HorizontalAlignment="Left" Margin="57,262,0,0" Name="label7" VerticalAlignment="Top" />

有没有办法在标签上添加第二个绑定,或者我是 SOL,我在过去一个小时左右尝试过谷歌搜索,并希望它很简单,可行吗?

4

1 回答 1

2

您可以将 aMultiBinding与自定义转换器一起使用,该转换器是OR从绑定到两者的输入值RadioButtons

<Label.Visibility>
    <MultiBinding>
        <MultiBinding.Converter>
            <local:LogicalOrConverter />
        </MultiBinding.Converter>
        <Binding Path="IsChecked" ElementName="radioButton4"/>
        <Binding Path="IsChecked" ElementName="radioButton6"/>
    </MultiBinding>
</Label.Visibility>
于 2012-07-27T23:49:58.017 回答