TriggerAction<T> クラス

定義

トリガーが満たされたときに実行されるユーザー定義アクションの汎用基底クラス。

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

型パラメーター

T

が動作する型 Invoke(T)

継承
TriggerAction<T>

注釈

次の例は、開発者がトリガーを使用してイベントに応答し、クラスを使用してコントロールプロパティの値を更新する方法を示して TriggerAction<T> います。 この例では、テキストの色に関する質問に回答するようにユーザーに求め、 ColorTriggerActionを呼び出して、ユーザーが「テキストの色が赤」と入力したときにテキストを赤にします。 この例では、ユーザーが文字列の編集を続けると、テキストが既定の色に変更されないことに注意する必要がありますが、開発者はさらにを実装し、その結果を取得するための終了アクションを指定することもできます。

次のように、 Triggerdemo名前空間で定義されている ColorTriggerAction クラスを使用します。

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

開発者は、次の XAML を使用して、テキスト領域の色を赤に変更することで、秘密の文字列に応答するページを作成でき Entry ます。

<?xml version="1.0" encoding="utf-8"?>
<ContentPage    xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:local="clr-namespace:TriggerDemo"
                x:Class="TriggerDemo.TriggerDemoPage">
<StackLayout VerticalOptions="Center">
<Label Text="What color is &quot;The text&quot;?"
               VerticalOptions="Center"
               HorizontalOptions="Center" />
<Entry Placeholder="Type answer here."
               VerticalOptions="Center"
               HorizontalOptions="Center"
               BackgroundColor="White">
<Entry.Triggers>
<Trigger TargetType="Entry"
                         Property="Text"
                         Value="The text is red" >
<Trigger.EnterActions>
<local:ColorTriggerAction />
</Trigger.EnterActions>
</Trigger>
</Entry.Triggers>
</Entry>
</StackLayout>
</ContentPage>

コンストラクター

TriggerAction<T>()

TriggerAction<T> クラスの新しいインスタンスを作成します。

プロパティ

AssociatedType

この TriggerAction を関連付けることができるオブジェクトの型を取得します。

(継承元 TriggerAction)

メソッド

Invoke(Object)

アプリケーション開発者は、トリガー条件が満たされたときに実行されるアクションを提供するため、このメソッドをオーバーライドします。

Invoke(T)

アプリケーション開発者は、トリガー条件が満たされたときに実行されるアクションを提供するため、このメソッドをオーバーライドします。

適用対象

こちらもご覧ください