Share via


MultiTrigger Class

Definition

Class that represents a list of property and binding conditions, and a list of setters that are applied when all of the conditions in the list are met.

[Xamarin.Forms.ContentProperty("Setters")]
public sealed class MultiTrigger : Xamarin.Forms.TriggerBase
type MultiTrigger = class
    inherit TriggerBase
Inheritance
System.Object
MultiTrigger
Attributes

Remarks

Developers can use a MultiTrigger to compare against property values on the control that contains it by using Trigger objects, or on any bound property (including those on the enclosing control) by using BindingCondition objects. These can be mixed in the same Conditions list.

The XML example below, when added to a Xamarin.Forms app with the correct project namespace, creates a UI that suggests that the user type in a secret and toggle a switch to check if the secret is correct. If the user enters "The text color is green", and toggles the Switch to its On position, then the text that the user typed into the Entry turns green. If either the text is altered to something other than the secret or the Switch is toggled to its Off position, the text returns to the default color

<?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>

Constructors

MultiTrigger(Type)

Initializes a new MultiTrigger instance.

Properties

BindingContext

Gets or sets object that contains the properties that will be targeted by the bound properties that belong to this BindableObject.

(Inherited from BindableObject)
Conditions

Gets the list of conditions that must be satisfied in ordeer for the setters in the Setters list to be invoked.

Dispatcher (Inherited from BindableObject)
EnterActions

Gets the list of TriggerAction objects that will be invoked when the trigger condition is met. Ignored for the EventTrigger class.

(Inherited from TriggerBase)
ExitActions

Gets the list of TriggerAction objects that will be invoked after the trigger condition is no longer met. Ignored for the EventTrigger class.

(Inherited from TriggerBase)
IsSealed

Gets a value that indicates whether or not the trigger is sealed.

(Inherited from TriggerBase)
Setters

Gets the list of Setter objects that will be applied when the list of conditions in the Conditions property are all met.

TargetType

The type of object to which this TriggerBase object can be attached.

(Inherited from TriggerBase)

Methods

ApplyBindings()

Apply the bindings to BindingContext.

(Inherited from BindableObject)
ClearValue(BindableProperty)

Clears any value set by SetValue for property.

(Inherited from BindableObject)
ClearValue(BindablePropertyKey)

Clears any value set by SetValue for the property that is identified by propertyKey.

(Inherited from BindableObject)
CoerceValue(BindableProperty) (Inherited from BindableObject)
CoerceValue(BindablePropertyKey) (Inherited from BindableObject)
GetValue(BindableProperty)

Returns the value that is contained in the BindableProperty.

(Inherited from BindableObject)
GetValues(BindableProperty, BindableProperty)
Obsolete.

For internal use by the Xamarin.Forms platform.

(Inherited from BindableObject)
GetValues(BindableProperty, BindableProperty, BindableProperty)
Obsolete.

For internal use by the Xamarin.Forms platform.

(Inherited from BindableObject)
IsSet(BindableProperty)

Returns true if the target property exists and has been set.

(Inherited from BindableObject)
OnBindingContextChanged()

Override this method to execute an action when the BindingContext changes.

(Inherited from BindableObject)
OnPropertyChanged(String)

Call this method from a child class to notify that a change happened on a property.

(Inherited from BindableObject)
OnPropertyChanging(String)

Call this method from a child class to notify that a change is going to happen on a property.

(Inherited from BindableObject)
RemoveBinding(BindableProperty)

Removes a previously set binding.

(Inherited from BindableObject)
SetBinding(BindableProperty, BindingBase)

Assigns a binding to a property.

(Inherited from BindableObject)
SetValue(BindableProperty, Object)

Sets the value of the specified property.

(Inherited from BindableObject)
SetValue(BindablePropertyKey, Object)

Sets the value of the propertyKey.

(Inherited from BindableObject)
SetValueCore(BindableProperty, Object, SetValueFlags)

For internal use by the Xamarin.Forms platform.

(Inherited from BindableObject)
UnapplyBindings()

Unapplies all previously set bindings.

(Inherited from BindableObject)

Events

BindingContextChanged

Raised whenever the BindingContext property changes.

(Inherited from BindableObject)
PropertyChanged

Raised when a property has changed.

(Inherited from BindableObject)
PropertyChanging

Raised when a property is about to change.

(Inherited from BindableObject)

Explicit Interface Implementations

IDynamicResourceHandler.SetDynamicResource(BindableProperty, String)

For internal use by the Xamarin.Forms platform.

(Inherited from BindableObject)

Extension Methods

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

Creates and applies a binding to a property.

SetBinding<TSource>(BindableObject, BindableProperty, Expression<Func<TSource,Object>>, BindingMode, IValueConverter, String)
Obsolete.

Creates and applies a binding from an expression.

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

Applies to

See also