MultiTrigger 類別

定義

此類別代表屬性和繫結條件的清單,以及清單中所有條件皆已滿足時所套用的 Setter 清單。

[Xamarin.Forms.ContentProperty("Setters")]
public sealed class MultiTrigger : Xamarin.Forms.TriggerBase
type MultiTrigger = class
    inherit TriggerBase
繼承
屬性

備註

開發人員可以使用 MultiTrigger 來比較 控制項上的屬性值,該 Trigger 控制項使用 物件,或是使用 物件在包含該控制項的任何系結屬性上 (包括封入控制項上的屬性值,) 使用 BindingCondition 物件。 這些可以混合在相同的 Conditions 清單中。

下列 XML 範例新增至具有正確專案命名空間的 Xamarin.Forms 應用程式時,會建立 UI,建議使用者輸入秘密,並切換參數來檢查秘密是否正確。 如果使用者輸入「文字色彩為綠色」,並將 切換 Switch 至其 On 位置,則使用者輸入的文字會變成 Entry 綠色。 如果文字變更為秘密以外的專案,或切換切換至其 Off 位置,則文字會傳回預設色彩

<?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:PropertyConditionDemo"
             x:Class="PropertyConditionDemo.PropertyConditionDemoPage">
<StackLayout VerticalOptions="Center">
<Label Text="Do you know the secret?"
               VerticalOptions="Center"
               HorizontalOptions="Center" />
<Entry Placeholder="Type the secret!"
               VerticalOptions="Center"
               HorizontalOptions="Center">
<Entry.Triggers>
<MultiTrigger TargetType="Entry" >
<MultiTrigger.Conditions>
<PropertyCondition Property="Text" Value="The text color is green" />
<BindingCondition Binding="{Binding Source={x:Reference checkSecret},
                                                            Path=IsToggled}"
                                          Value="true" />
</MultiTrigger.Conditions>
<Setter Property="TextColor"
                        Value="Color.Green" />
</MultiTrigger>
</Entry.Triggers>
</Entry>
<Label Text="Check the secret?"
               VerticalOptions="Center"
               HorizontalOptions="Center" />
<Switch x:Name="checkSecret"
                VerticalOptions="Center"
                HorizontalOptions="Center" />
</StackLayout>
</ContentPage>

建構函式

MultiTrigger(Type)

初始化新的 MultiTrigger 執行個體。

屬性

BindingContext

取得或設定物件,這個物件包含屬於此 BindableObject 屬性繫結屬性將設為目標的屬性。

(繼承來源 BindableObject)
Conditions

取得條件的清單,必須滿足這些條件,才能叫用 Setters 清單中的 Setter。

Dispatcher

此類別代表屬性和繫結條件的清單,以及清單中所有條件皆已滿足時所套用的 Setter 清單。

(繼承來源 BindableObject)
EnterActions

取得符合觸發條件時要叫用的 TriggerAction 物件清單。 若為 EventTrigger 類別請予以略過。

(繼承來源 TriggerBase)
ExitActions

取得觸發條件不再符合之後要叫用的 TriggerAction 物件清單。 若為 EventTrigger 類別請予以略過。

(繼承來源 TriggerBase)
IsSealed

取得值,指出是否密封觸發程序。

(繼承來源 TriggerBase)
Setters

取得 Setter 物件的清單,當 Conditions 屬性中的條件清單皆已满足時,便會套用這些物件。

TargetType

可附加這個 TriggerBase 物件的目標物件類型。

(繼承來源 TriggerBase)

方法

ApplyBindings()

將繫結套用至 BindingContext

(繼承來源 BindableObject)
ClearValue(BindableProperty)

清除 SetValue 針對 property 所設定的任何值。

(繼承來源 BindableObject)
ClearValue(BindablePropertyKey)

清除 SetValue 針對 propertyKey 所識別屬性設定的任何值。

(繼承來源 BindableObject)
CoerceValue(BindableProperty)

此類別代表屬性和繫結條件的清單,以及清單中所有條件皆已滿足時所套用的 Setter 清單。

(繼承來源 BindableObject)
CoerceValue(BindablePropertyKey)

此類別代表屬性和繫結條件的清單,以及清單中所有條件皆已滿足時所套用的 Setter 清單。

(繼承來源 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)

此類別代表屬性和繫結條件的清單,以及清單中所有條件皆已滿足時所套用的 Setter 清單。

SetAppThemeColor(BindableObject, BindableProperty, Color, Color)

此類別代表屬性和繫結條件的清單,以及清單中所有條件皆已滿足時所套用的 Setter 清單。

SetBinding(BindableObject, BindableProperty, String, BindingMode, IValueConverter, String)

建立並將繫結套用至屬性。

SetBinding<TSource>(BindableObject, BindableProperty, Expression<Func<TSource,Object>>, BindingMode, IValueConverter, String)
已過時。

從運算式建立及套用繫結。

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

此類別代表屬性和繫結條件的清單,以及清單中所有條件皆已滿足時所套用的 Setter 清單。

適用於

另請參閱