DataTrigger クラス

定義

条件が満たされたときに適用される Setter オブジェクトのリストと共に、任意のバインドの条件を表すクラス。

[Xamarin.Forms.ContentProperty("Setters")]
[Xamarin.Forms.Xaml.AcceptEmptyServiceProvider]
public sealed class DataTrigger : Xamarin.Forms.TriggerBase, Xamarin.Forms.Xaml.IValueProvider
type DataTrigger = class
    inherit TriggerBase
    interface IValueProvider
継承
属性
実装

注釈

クラスは、 DataTrigger 他のコントロールの値、およびそのコントロールが追加されたコントロールのプロパティを確認するのに適しています。 つまり、既定のバインディングコンテキストは、追加されたコントロールです。

次の XML の例では、シークレットを入力するようにユーザーに求めています。 "テキストの色は緑です" と表示されます。 ユーザーが "the" と入力すると、入力テキストが赤に変わります。 ユーザーがシークレットを完了すると、ラベルのテキストが緑色に変わります。 ユーザーがシークレットを編集した場合、コードは既定の色に戻ります。 この例では、外側のコントロール (Entry から 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="Can you tell me the secret?" VerticalOptions="Center" HorizontalOptions="Center">
<Label.Triggers>
<DataTrigger TargetType="Label"
                    Binding="{Binding Source={x:Reference checkEntry},
                                      Path=Text}"
                    Value="The text color is green">
<Setter Property="TextColor" Value="Color.Green" />
</DataTrigger>
</Label.Triggers>
</Label>
<Entry Placeholder="Type the secret here." x:Name="checkEntry" VerticalOptions="Center" HorizontalOptions="Center">
<Entry.Triggers>
<DataTrigger TargetType="Entry"
                    Binding="{Binding Text}"
                    Value="The">
<Setter Property="TextColor" Value="Red" />
</DataTrigger>
</Entry.Triggers>
</Entry>
</StackLayout>
</ContentPage>

コンストラクター

DataTrigger(Type)

新しい DataTrigger インスタンスを初期化します。

プロパティ

Binding

セッターを呼び出すタイミングを決定するために Value と比較される値を持つバインドを取得または設定します。

BindingContext

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

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

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

(継承元 TriggerBase)
ExitActions

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

(継承元 TriggerBase)
IsSealed

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

(継承元 TriggerBase)
Setters

Binding プロパティで指定されたバインドが Value と等しくなった場合に適用される Setter オブジェクトのリストを取得します。

TargetType

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

(継承元 TriggerBase)
Value

セッターを適用する、Binding プロパティによって指定されたバインドの値を取得または設定します。

メソッド

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)
IValueProvider.ProvideValue(IServiceProvider)

XAML インフラストラクチャによる内部使用向け。

拡張メソッド

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)

適用対象