我有四个int属性ProOneProTwoProThreeProFour
我必须在多值转换器(即((ProOne == ProTwo) || (ProThree == ProFour)))中实现 bool 逻辑VisibilityCheckConverter。基于逻辑,多值转换器VisibilityCheckConverter返回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>

关于c# - 如何通过WPF DataTrigger在多值转换器中传递多个参数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35266611/

10-12 19:43