Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
StephanArnas opened this issue Sep 8, 2024 · 5 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@StephanArnas
Copy link

StephanArnas commented Sep 8, 2024

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

@StephanArnas StephanArnas added the t/bug Something isn't working label Sep 8, 2024
Copy link
Contributor

github-actions bot commented Sep 8, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@QianaJiao
Copy link

This issue has been verified using latest Visual Studio 17.12.0 Preview 1.0 (8.0.82 &8.0.3), Can repro it on Android /iOS platforms.

@QianaJiao QianaJiao added platform/android 🤖 platform/iOS 🍎 s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Sep 9, 2024
@mattleibow mattleibow added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Sep 11, 2024
@mattleibow mattleibow added this to the Backlog milestone Sep 11, 2024
@mattleibow
Copy link
Member

mattleibow commented Sep 13, 2024

A simpler repro case:

<CollectionView ItemsSource="{Binding Items}">
    <CollectionView.ItemTemplate>
        <DataTemplate>
            <ContentView>
                <ContentView.Triggers>
                    <DataTrigger TargetType="ContentView" Binding="{Binding .}" Value="Second">
                        <Setter Property="BackgroundColor" Value="LightBlue"/>
                    </DataTrigger>
                </ContentView.Triggers>
                <Label Text="{Binding .}" FontSize="24"/>
            </ContentView>
        </DataTemplate>
    </CollectionView.ItemTemplate>
</CollectionView>

Archive.zip

@mattleibow
Copy link
Member

Duplicate of #22914

@mattleibow mattleibow marked this as a duplicate of #22914 Sep 13, 2024
@mattleibow
Copy link
Member

@StephanArnas this is a duplicate of the other issue as everything is working from your code, except that for some cases, we are not removing the background of the unselected content view.

A workaround would be to set the Background of the content view to transparent - so the data trigger has a non-null value to return to. Right now, it is going from null to purple, and then back to null which has this issue. But transparent, purple, transparent is working fine.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants