如何通过 WPF DataTrigger 在多值转换器中传递多个参数

How to Pass multiple parameter in Multivalue Converter Over WPF DataTrigger

我有四个 int 属性 ProOneProTwoProThreeProFour

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

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

如何使用具有多个参数的多值转换器编写 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>

你可以这样做

<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>