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 めます。 開発者は、この例では、ユーザーが文字列の編集を続けるときにテキストを既定の色に戻しませんが、開発者は、その結果を取得するために終了アクションを追加で実装して指定できることに注意してください。

以下の ColorTriggerAction クラスを名前空間で定義します TriggerDemo

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)

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

適用対象

こちらもご覧ください