[Xamarin Blog] Triggers in Xamarin.Forms RRS feed

  • Question

  • User15531 posted

    Read the full article to learn about Triggers in Xamarin.Forms.

    Please use this thread to discuss or ask questions.

    Wednesday, February 25, 2015 2:13 PM

All replies

  • User5299 posted

    From a high-level perspective, there seems to be an overlap between Behaviors and Triggers. When do you choose one over the other?

    Wednesday, February 25, 2015 11:52 PM
  • User70757 posted

    A very dumb question, but, I assume there's a way to do all of this programatically?

    Thursday, February 26, 2015 9:13 PM
  • User42522 posted

    @JosephAntolick Yes, it can be done. One example is discussed here.

    Friday, February 27, 2015 3:47 PM
  • User3542 posted

    From a dev perspective i've got a couple of questions:

    • What is the difference between using MultiTrigger with one trigger and DataTrigger? Also the naming is inconsistent.
    • Why should I use Behaviors instead of an Event Trigger ?
    Saturday, February 28, 2015 8:12 AM
  • User82074 posted

    Hello ,

    I 'm having problems with this code, can you help me:

    <Image > <Image.Trigger> <DataTrigger TargetType="Image" Binding="{Binding Status}" Value="Identified"> <Setter Property="Source" Value="Icon_Identified.png"/> </DataTrigger> <DataTrigger TargetType="Image" Binding="{Binding Status}" Value="Unidentified"> <Setter Property="Source" Value="Icon_Unidentified.png"/> </DataTrigger> </Image.Trigger> </Image>

    Exception: "TargetType is required"

    Monday, March 16, 2015 5:00 PM
  • User82074 posted


    Friday, March 20, 2015 8:11 AM
  • User82074 posted

    @NishAnil can we use triggers inside Data Templates in X.F. 1.4.1 ????

    Tuesday, April 21, 2015 3:33 PM
  • User112992 posted

    There is a bug logged for it. It seems like not right now, unfortunately. i'm working around the issue by using validators instead for datatemplates.

    Tuesday, April 21, 2015 3:44 PM
  • User125738 posted

    I'm trying to use the following Xaml to set the background color of the selected item in my ListView using a MultiTrigger, but the app crashes with a seemingly unrelated error when I include the section below. Without that portion of the Xaml the list works fine, but I can't set the background of the selected item in the list. Here is the Xaml:

    <ListView x:Name="resultsListView" ItemsSource="{Binding Suggestions}"> <ListView.Resources> <Style TargetType="ListViewItem"> <Style.Triggers> <MultiTrigger TargetType="ListViewItem"> <MultiTrigger.Conditions> <BindingCondition Binding="{Binding Path=Selected}" Value="true" /> <BindingCondition Binding="{Binding Path=Focused}" Value="true" /> </MultiTrigger.Conditions> <Setter Property="ListViewItem.BackColor" Value="Pink" /> </MultiTrigger> </Style.Triggers> </Style> </ListView.Resources> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout Orientation="Horizontal" Padding="10,5,10,5" Spacing="0"> <Label Text="{Binding}" LineBreakMode="NoWrap" HorizontalOptions="FillAndExpand"></Label> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

    I tried using PropertyConditions, too. That yielded the same result.

    <MultiTrigger.Conditions> <PropertyCondition Property="ListViewItem.Selected" Value="true" /> <PropertyCondition Property="ListViewItem.Focused" Value="true" /> </MultiTrigger.Conditions>

    And idea what I'm doing wrong?

    Thursday, December 3, 2015 4:13 AM
  • User283453 posted

    @JonCortez said: From a high-level perspective, there seems to be an overlap between Behaviors and Triggers. When do you choose one over the other?

    Old post, still I'm wondering too If I should use one or another ... still no answer to this question on this post.

    Wednesday, January 4, 2017 12:55 PM
  • User169691 posted

    Should be:


    .... but I am having problems with setting the image source this way myself...

    Thursday, January 19, 2017 1:54 AM
  • User291796 posted
                <Image Source="image_for_false.png">
                        <DataTrigger TargetType="Image" Binding="{Binding BooleanProperty}" Value="True">
                            <Setter Property="Source" Value="image_for_true.png" />
    Tuesday, January 31, 2017 8:58 AM
  • User303816 posted

    can use Trigger for Viewcell? like

    Thursday, July 27, 2017 12:35 PM
  • User347486 posted

    i am using picker in my project but multitrigger is not working there ... Path="Text.Lenght" is used for Entries but what for pickers ..

    i want user fill all enteries to access button event , i have three pickers in there .. any one have code ??

    Friday, September 15, 2017 12:21 PM