Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Pass multiple parameter in Multivalue Converter Over WPF DataTrigger

I'm having four int Property ProOne, ProTwo, ProThree and ProFour

I have to Implement the Boolean Logic ((ProOne == ProTwo) || (ProThree == ProFour)) in the Multivalue Converter namely VisibilityCheckConverter. Based on the Logic the Multivalue Converter VisibilityCheckConverter returns True or False.

Now I need to pass the four properties to the Converter over DataTrigger, Based on the Value, I have to change the Buttons Visibility to Visible

How does one write the a DataTrigger using Multivalue Converter with multiple parameters?

Sample Piece of XAML Code:

<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>
like image 870
B.Balamanigandan Avatar asked Feb 08 '16 09:02

B.Balamanigandan


1 Answers

You can do something like this

<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>
like image 151
Nikhil Agrawal Avatar answered Oct 29 '22 14:10

Nikhil Agrawal