Xamarin.forms: [Bug] Trigger not correctly resetting to default value when none of the style trigger conditions are met

Created on 10 Feb 2020  路  3Comments  路  Source: xamarin/Xamarin.Forms

When two (or more) triggers set a property value consecutively, then the second trigger keep the first trigger value and not the original. When the first and second trigger exited, the value is set to the previous trigger's value.

Steps to Reproduce

  1. Create style on CheckBox with triggers
  2. Write a Trigger on IsChecked property and write setter on background property
  3. Write a second trigger on IsEnabled property and write setter on background property
  4. Write a third MultiTrigger on IsChecked True and IsEnabled false and write setter on background property
  5. Create a view with a disable and checked checkbox by default
  6. Add a button to switch checkbox to enabled and unchecked.

Expected Behavior

The checkbox must have the unchecked and enable background (default values)

Actual Behavior

The checkbox takes the isChecked background

Basic Information

  • Version with issue: Xamarin.Forms 4.X
  • Last known good version: no version
  • IDE: Visual Studio 2019
  • Platform Target Frameworks: all platform

Reproduction Link

Clone this repository and launch TestApp. Open InteractivityView or InteractivityView2
https://github.com/RenaudAvenas/Oxard.XControls

https://github.com/xamarin/Xamarin.Forms/files/4231567/BugTrigger.zip

Workaround

I rewrite Triggers in my project https://github.com/RenaudAvenas/Oxard.XControls Use Interactivity class and custom triggers

triggers 1 bug up-for-grabs

Most helpful comment

same issue on UWP with 3 DataTriggers

All 3 comments

@RenaudAvenas is it possible for you to pair down your repro to just using Forms Controls
It's a little bit tricky to follow through the custom controls to narrow down to the issue you are having

I join a simpliest project below with the bug. I create a new project from stratch and modify only MainPage.xaml and MainPage.xaml.cs. I use a basic XF Entry to reproduce the bug.
BugTrigger.zip

same issue on UWP with 3 DataTriggers

Was this page helpful?
0 / 5 - 0 ratings