6

我有四个intProperty ProOne,ProTwoProThreeProFour

我必须((ProOne == ProTwo) || (ProThree == ProFour))在多值转换器中实现布尔逻辑,即VisibilityCheckConverter。基于逻辑,多值转换器VisibilityCheckConverter返回TrueFalse

现在我需要通过 DataTrigger 将这四个属性传递给 Converter,根据值,我必须将 Buttons Visibility 更改为 Visible

如何使用具有多个参数的 Multivalue Converter 编写 DataTrigger

XAML 代码示例:

<ControlTemplate.Triggers>
    <DataTrigger Property="{Binding , Converter={StaticResource VisibilityCheckConverter,ConverterParameter=ProOne ProTwo ProThree ProFour}}" Value="true">
        <Setter TargetName="Button" Property="Visibility" Value="Visible" />
    </DataTrigger>
</ControlTemplate.Triggers>
4

1 回答 1

15

你可以做这样的事情

<Style.Triggers>
    <DataTrigger Value="True">
        <DataTrigger.Binding>
            <MultiBinding Converter="{StaticResource VisibilityCheckConverter}">
                <Binding Path="ProOne" />
                <Binding Path="ProTwo" />
                <Binding Path="ProThree" />
                <Binding Path="ProFour" />
            </MultiBinding>
        </DataTrigger.Binding>
        <Setter TargetName="Button" Property="Visibility" Value="Visible" />
    </DataTrigger>
</Style.Triggers>
于 2016-02-08T10:02:14.443 回答