locked
MultiTrigger with or condition RRS feed

  • Question

  • User266970 posted

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

    Wednesday, January 10, 2018 2:55 AM

All replies

  • User28549 posted

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

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

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

    Happy coding!

    Tuesday, September 11, 2018 3:37 PM
  • User374443 posted

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

    Wednesday, April 7, 2021 2:16 PM