Skip to content

The DataTrigger in the CollectionView inside the Popup doesn't work correctly when scrolling #24655

Closed

Description

Description

I define a DataTrigger on a ContentView for a ItemTemplate on a CollectionView.
My goal is to change the background color on the row where the SelectedItem is matching the value.

contentView.Triggers.Add(new DataTrigger(typeof(ContentView))
{
    Binding = new Binding("."),
    Value = SelectedItem,
    Setters =
    {
        new Setter
        {
            Property = VisualElement.BackgroundColorProperty,
            Value = ResourceHelper.GetThemeColor("PrimaryDark", "Primary")
        }
    }
});

CleanShot 2024-09-08 at 16 25 59

When I select a value like United States, I open again the picker I can see United States is selected but if I scroll, many row will have a background. It's should not be possible with my Triggers.
If I scroll down very fast and I scroll up, I have more background appearing on my rows coming from nowhere.

Steps to Reproduce

  1. Clone the project and restore it.
  2. Uncomment the line 76-88 in CollectionPopup.xaml.cs file
  3. Run the application on Android.
  4. Go on the page 'Picker with popup demo'.
  5. Open the Country picker and select United States.
  6. Open again the Country picker, the United State is selected, but every items, matching the height size of the device is selected.

Link to public reproduction project repository

https://github.com/StephanArnas/Blog_MAUI_ComponentLibrary/tree/articles/part_4

Version with bug

8.0.82 SR8.2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

Android 14, iOS 15

Did you find any workaround?

No workaround for now, I desactivate the trigger to not confuse my users.

Relevant log output

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions