dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.05k stars 1.73k forks source link

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

Open polqnaP opened 1 year ago

polqnaP commented 1 year ago

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"/>
  2. Add ItemsSource to the CollectionView.

    var items = new[] { "Item 1", "Item 2", "Item 3" };
    this.colView.ItemsSource = items;
  3. 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;
  3. Add ItemTemplate containing a Label.

  4. 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>
  5. 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

PureWeen commented 1 year ago

This should be fixed on the next release of MAUI

If the next release doesn't resolve please leave a comment and we can reopen.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost commented 1 year ago

Hi @polqnaP. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

polqnaP commented 1 year ago

Hello, the issue still persists with the latest version of MAUI - 7.0.59

ghost commented 1 year ago

Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!

XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.7.0 Preview 2.0. Repro on Windows 11 with below Project: CollectionViewDefaultPointerOver_WinUI.zip

BeepBeepBopBop commented 3 months ago

Hello, I am experiencing the same issue. Has anybody found a solution/workaround for this ? Thanks for any help.

BeepBeepBopBop commented 1 week ago

This should be fixed on the next release of MAUI

If the next release doesn't resolve please leave a comment and we can reopen.

@PureWeen

Hello, I am using the latest .net9 preview version (9.0.0-preview.7) and the issue still persists.

I am really surprised to see that it was expected to be fixed in the next release from 1 and a half year ago, and I am gueninely wondering: what does this actually mean ?

From my point of view there seems to be 2 options:

1 it turned out the solution you expected was not enough to fix the problem -> it is fine but could you please provide that information ? It was quite a long time ago now and the other releases did not seem to fix the issue, does this mean nobody is working on this anymore or maybe nobody is able to fix it ?

2 you really expected the issue to be fixed 1+ year ago -> it is unfortunately not the case, can you check again and make sure that what you thought would fix the issue 1+ year ago is brought in the next version ?

Either way: could you please communicate some info regarding this, is there anybody working on this, can we realistically hope for a fix in a relatively short period of time, if not do you have some advice regarding a solid workaround ?

Thank you for your time.

BeepBeepBopBop commented 6 days ago

Hello, after spending a lot of time struggling with a lot of weird issues even with the most basic usage of CollectionView (especially on Windows) I decided to implement a CustomCollectionView control based on custom VisualStates and GestureRecognizers.

It is very basic and you probably will have to modify it to make it suit your needs but if you currently are where I was just a few months ago struggling to learn MAUI/XAML, it will at least give you a good base to move forward with a solution that works for you.