Skip to content

[WinUI] CollectionView has default native PointerOver state which cannot be removed #13197

Open

Description

Description

On WinUI:
CollectionView's native ListViewItems have default PointerOver state which applies gray background on the items.
This blocks customizations in the PointerOver state in the ItemTemplate of the CollectionView, especially when using Color with alpha.

Steps to Reproduce

Case 1:

  1. Add CollectionView with SelectionMode="Single".
<CollectionView HeightRequest="500" x:Name="colView" SelectionMode="Single"/>
  1. Add ItemsSource to the CollectionView.
var items = new[] { "Item 1", "Item 2", "Item 3" };
this.colView.ItemsSource = items;
  1. Run the app in WinUI

Expected: When hovering over the items there should be no change in the visual state.
Actual: When hovering over the items there is a grey background color applied.
image

Case 2:

  1. Add CollectionView with SelectionMode="Single".
  2. Add ItemsSource to the CollectionView.
var items = new[] { "Item 1", "Item 2", "Item 3" };
this.colView.ItemsSource = items;
  1. Add ItemTemplate containing a Label.
  2. Set VisualStateManager.VisualStateGroups to the Label and in the PointerOver state change the BackgroundColor of the Label to some Color (with or without with alpha).
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Label Text="{Binding .}">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroupList>
                            <VisualStateGroup Name="CommonStates">
                                <VisualState Name="Normal" />
                                <VisualState Name="PointerOver">
                                    <VisualState.Setters>
                                        <Setter Property="BackgroundColor" Value="#40FFFF00"/>
                                        <Setter Property="TextColor" Value="Purple" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState Name="Disabled"/>
                                <VisualState Name="Selected"/>
                            </VisualStateGroup>
                        </VisualStateGroupList>
                    </VisualStateManager.VisualStateGroups>
                </Label>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
  1. Run the app in WinUI

Expected: When hovering over the Labels inside the items if the CollectionView only the set in point 4 color should be seen.
Actual: When hovering over the Labels inside the items if the CollectionView the default native ListViewItem pointerover background color is displayed, as well as the set color in step 4. If the color from point 4 has alpha the grey color of the item is seen through due to the transparency.
image

Link to public reproduction project repository

https://github.com/telerik/ms-samples/tree/main/Maui/CollectionViewDefaultPointerOver_WinUI

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows SDK 10.0.19041

Did you find any workaround?

No

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

    Labels

    area-controls-collectionviewCollectionView, CarouselView, IndicatorViewplatform/windows 🪟s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions