TriggerAction<T> TriggerAction<T> Class


A generic base class for user-defined actions that are performed when a trigger condition is met.

public abstract class TriggerAction<T> : Xamarin.Forms.TriggerAction where T : BindableObject
type TriggerAction<'T (requires 'T :> BindableObject)> = class
    inherit TriggerAction

Type Parameters


The type on which Invoke(T) acts.



The example below shows how developers can use a trigger to respond to events and update the value of a control property by using TriggerAction<T> classes. The example prompts the user to answer a question about the color of the text, and then calls ColorTriggerAction to turn the text red when the user types "The text color is red". Developers should note that, while this example does not change the text back to the default color when the user continues to edit the string, the developer could additionally implement and specify an exit action to obtain that result.

With the ColorTriggerAction class below defined in the TriggerDemo namespace:

public class ColorTriggerAction : TriggerAction<Entry>
    protected override void Invoke(Entry sender)
        sender.TextColor = Color.Red;

the developer can use the XAML below to create the page that responds to the secret string by changing the color of the Entry text area to red.

<?xml version="1.0" encoding="utf-8"?>
<ContentPage    xmlns=""
    <StackLayout VerticalOptions="Center">
        <Label Text="What color is &quot;The text&quot;?"
               HorizontalOptions="Center" />
        <Entry Placeholder="Type answer here."
                <Trigger TargetType="Entry"
                         Value="The text is red" >
                        <local:ColorTriggerAction />


TriggerAction<T>() TriggerAction<T>()

Creates a new instance of the TriggerAction<T> class.


Invoke(Object) Invoke(Object)

Application developers override this method to provide the action that is performed when the trigger condition is met.

Invoke(T) Invoke(T)

Application developers override this method to provide the action that is performed when the trigger condition is met.


AssociatedType AssociatedType

Gets the type of the objects with which this TriggerAction can be associated.

(Inherited from TriggerAction)

Extension Methods

LoadFromXaml<TXaml>(TXaml, String) LoadFromXaml<TXaml>(TXaml, String)

Returns an initialized view by loading the specified xaml.

LoadFromXaml<TXaml>(TXaml, Type) LoadFromXaml<TXaml>(TXaml, Type)

Returns a TXaml with the properties that are defined in the application manifest for callingType.

Applies to

See also