Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

MultiTrigger with or condition

AmiteshSharma.5497AmiteshSharma.5497 NZMember ✭✭
edited January 2018 in Xamarin.Forms

I have added a trigger on my stacklayout to make it visible when one or more conditions are met. I dont want to create a property in my model to bind to the stacklayout. My issue is that the trigger treats the conditions with AND operator.
Is there a way to make it treat the conditions with OR operator? So in my case if IsPrivate is true or IsAlert is true the stacklayout should be visible.

Sample code below:


  • ChaseFlorellChaseFlorell CAInsider, University mod
    edited September 2018

    Set the value of "IsVisible" is "False" by default, then use separate DataTriggers instead of a MultiTrigger

    <StackLayout IsVisible="False">
            <DataTrigger TargetType="StackLayout" Binding="{Binding IsPrivate}" Value="True">
                <Setter Property="IsVisible" Value="True" />
            <DataTrigger TargetType="StackLayout" Binding="{Binding IsAlert}" Value="True">
                <Setter Property="IsVisible" Value="True" />

    Doing this will always have the StackLayout visibility set to False unless IsPrivate is true OR IsAlert is true

    Happy coding!

  • MNadeemMNadeem Member ✭✭

    Thanks @ChaseFlorell your code helpful for me. thanks a lot.

Sign In or Register to comment.