EventTrigger クラス

定義

トリガー イベントとイベントが発生したときに呼び出される TriggerAction オブジェクトの一覧を表すクラス。

[Xamarin.Forms.ContentProperty("Actions")]
public sealed class EventTrigger : Xamarin.Forms.TriggerBase
type EventTrigger = class
    inherit TriggerBase
継承
属性

注釈

次の例は、開発者がイベントトリガーを使用してイベントに応答し、コントロールプロパティの値を更新する方法を示しています。

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

public class ColorTriggerAction : TriggerAction<Entry>
{
  protected override void Invoke(Entry sender)
  {
      Color[] color ={ Color.Red,
                       Color.Orange,
                       Color.Yellow,
                       Color.Green,
                       Color.Blue,
                       Color.Indigo,
                       Color.Violet };
      sender.TextColor = color[sender.Text.Length % color.Length];
  }
}

開発者は、次の 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="Do you see colors?"
             VerticalOptions="Center"
             HorizontalOptions="Center" />
<Entry Placeholder="Type stuff here."
             VerticalOptions="Center"
             HorizontalOptions="Center"
             BackgroundColor="Black">
<Entry.Triggers>
<EventTrigger Event="TextChanged" >
<local:ColorTriggerAction />
</EventTrigger>
</Entry.Triggers>
</Entry>
</StackLayout>
</ContentPage>

コンストラクター

EventTrigger()

新しい EventTrigger のインスタンスを作成します。

プロパティ

Actions

Event プロパティにより識別されるイベントが発生したときに呼び出される TriggerAction オブジェクトの一覧を取得します。

BindingContext

バインドされたプロパティのうち、この BindableObject に属するプロパティの対象となるプロパティが含まれるオブジェクトを取得または設定します。

(継承元 BindableObject)
Dispatcher (継承元 BindableObject)
EnterActions

トリガー条件が満たされたときに呼び出される TriggerAction オブジェクトの一覧を取得します。 EventTrigger クラスの場合、無視されます。

(継承元 TriggerBase)
Event

Actions に含まれるアクションを呼び出すイベントの名前を取得または設定します。

ExitActions

トリガー条件が満たされなくなった後に呼び出される TriggerAction オブジェクトの一覧を取得します。 EventTrigger クラスの場合、無視されます。

(継承元 TriggerBase)
IsSealed

トリガーが封印されているかどうかを示す値を取得します。

(継承元 TriggerBase)
TargetType

この TriggerBase オブジェクトを添付できるオブジェクトの型。

(継承元 TriggerBase)

メソッド

ApplyBindings()

BindingContext にバインディングを適用します。

(継承元 BindableObject)
ClearValue(BindableProperty)

propertySetValue によって設定された値を消去します。

(継承元 BindableObject)
ClearValue(BindablePropertyKey)

propertyKey によって識別されるプロパティの SetValue によって設定される値を消去します。

(継承元 BindableObject)
CoerceValue(BindableProperty) (継承元 BindableObject)
CoerceValue(BindablePropertyKey) (継承元 BindableObject)
GetValue(BindableProperty)

BindableProperty に含まれる値を返します。

(継承元 BindableObject)
GetValues(BindableProperty, BindableProperty)
互換性のために残されています。

Xamarin.Forms プラットフォームによる内部使用向け。

(継承元 BindableObject)
GetValues(BindableProperty, BindableProperty, BindableProperty)
互換性のために残されています。

Xamarin.Forms プラットフォームによる内部使用向け。

(継承元 BindableObject)
IsSet(BindableProperty)

ターゲット プロパティが存在し、設定されている場合、true を返します。

(継承元 BindableObject)
OnBindingContextChanged()

このメソッドをオーバーライドし、BindingContext が変更されたときにアクションを実行します。

(継承元 BindableObject)
OnPropertyChanged(String)

子クラスからこのメソッドを呼び出し、プロパティが変更されたことを通知します。

(継承元 BindableObject)
OnPropertyChanging(String)

子クラスからこのメソッドを呼び出し、プロパティで変更が行われることを通知します。

(継承元 BindableObject)
RemoveBinding(BindableProperty)

以前に設定されたバインディングを削除します。

(継承元 BindableObject)
SetBinding(BindableProperty, BindingBase)

プロパティにバインディングを割り当てます。

(継承元 BindableObject)
SetValue(BindableProperty, Object)

指定したプロパティの値を設定します。

(継承元 BindableObject)
SetValue(BindablePropertyKey, Object)

propertyKey の値を設定します。

(継承元 BindableObject)
SetValueCore(BindableProperty, Object, SetValueFlags)

Xamarin.Forms プラットフォームによる内部使用向け。

(継承元 BindableObject)
UnapplyBindings()

以前に設定されたバインディングをすべて解除します。

(継承元 BindableObject)

イベント

BindingContextChanged

BindingContext プロパティが変更されるたびに発生します。

(継承元 BindableObject)
PropertyChanged

プロパティが変更されたときに発生します。

(継承元 BindableObject)
PropertyChanging

プロパティが変更されようとしているときに発生します。

(継承元 BindableObject)

明示的なインターフェイスの実装

IDynamicResourceHandler.SetDynamicResource(BindableProperty, String)

Xamarin.Forms プラットフォームによる内部使用向け。

(継承元 BindableObject)

拡張メソッド

GetPropertyIfSet<T>(BindableObject, BindableProperty, T)
SetAppThemeColor(BindableObject, BindableProperty, Color, Color)
SetBinding(BindableObject, BindableProperty, String, BindingMode, IValueConverter, String)

プロパティにバインドを作成し、適用します。

SetBinding<TSource>(BindableObject, BindableProperty, Expression<Func<TSource,Object>>, BindingMode, IValueConverter, String)
互換性のために残されています。

式からバインドを作成し適用します。

SetOnAppTheme<T>(BindableObject, BindableProperty, T, T)

適用対象

こちらもご覧ください