[FIXED] Is there any way to keep multiple conditions in triggers

Issue

I am using xamarin.forms. In xaml I have wants to use triggers like below

if(Theme=="Operational" && Selected == true)
//set properties
else if(Theme=="Digital" && Selected == true)
//set properties

Theme and Selected are binding properties. Currently I am navigating to different xaml pages based on above conditions. I am trying triggers like this.

<Grid.Triggers>
  <DataTrigger
     Binding="{Binding TabButtons[0].BtnSelected}"
     TargetType="Grid"
     Value="True">
     <Setter Property="IsVisible" Value="False" />
  </DataTrigger>
</Grid.Triggers>

How can I do it ?

Solution

Try using MultiTrigger like this

<Grid.Triggers>
    <MultiTrigger TargetType="Grid">
        <MultiTrigger.Conditions>
            <BindingCondition Binding="{Binding Theme}" Value="OPERATIONAL" />
            <BindingCondition Binding="{Binding Selected }" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="IsVisible" Value="False" />
    </MultiTrigger>
    <MultiTrigger TargetType="Grid">
        <MultiTrigger.Conditions>
            <BindingCondition Binding="{Binding Theme}" Value="DIGITAL" />
            <BindingCondition Binding="{Binding Selected}" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="IsVisible" Value="True" />
    </MultiTrigger>
</Grid.Triggers>

Answered By – Sugitha

Answer Checked By – Marilyn (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published