Xamarin.Forms Guides | Samples

Xamarin.Forms.MultiTrigger Class

Class that represents a list of property and binding conditions, and a list of setters that are applied when all of the conditions in the list are met.

See Also: MultiTrigger


public sealed class MultiTrigger : TriggerBase

See Also


Developers can use a MultiTrigger to compare against property values on the control that contains it by using PropertyTrigger objects, or on any bound property (including those on the enclosing control) by using BindingCondition objects. These can be mixed in the same MultiTrigger.Conditions list.

The XML example below, when added to a Xamarin.Forms app with the correct project namespace, creates a UI that suggests that the user type in a secret and toggle a switch to check if the secret is correct. If the user enters "The text color is green", and toggles the Switch to its On position, then the text that the user typed into the Entry turns green. If either the text is altered to something other than the secret or the Switch is toggled to its Off position, the text returns to the default color

XML Example

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
    <StackLayout VerticalOptions="Center">
        <Label Text="Do you know the secret?"
               HorizontalOptions="Center" />
        <Entry Placeholder="Type the secret!"
                <MultiTrigger TargetType="Entry" >
                        <PropertyCondition Property="Text" Value="The text color is green" />
                        <BindingCondition Binding="{Binding Source={x:Reference checkSecret},
                                          Value="true" />
                    <Setter Property="TextColor"
                        Value="Color.Green" />
        <Label Text="Check the secret?"
               HorizontalOptions="Center" />
        <Switch x:Name="checkSecret"
                HorizontalOptions="Center" />


Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions:,,,

The members of Xamarin.Forms.MultiTrigger are listed below.

See Also: TriggerBase

Public Constructors

Initializes a new MultiTrigger instance.

Public Properties

ConditionsIList<Condition>. Gets the list of conditions that must be satisfied in ordeer for the setters in the MultiTrigger.Setters list to be invoked.
SettersIList<Setter>. Gets the list of Setter objects that will be applied when the list of conditions in the MultiTrigger.Conditions property are all met.