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

CollectionView does not highlight selected item on Android but works on windows #13885

Closed
KWodarczyk opened this issue Mar 13, 2023 · 3 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/windows 🪟 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working

Comments

@KWodarczyk
Copy link

Description

CollectionView does not highlight selected item on Android but works on windows

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiTest.MainPage">
    <ContentPage.Resources>
        <Style TargetType="Frame">
            <Setter Property="VisualStateManager.VisualStateGroups">
                <VisualStateGroupList>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal" >
                            <VisualState.Setters>
                                <Setter Property="BackgroundColor" Value="Green" />
                            </VisualState.Setters>
                        </VisualState>
                        <VisualState x:Name="Selected">
                            <VisualState.Setters>
                                <Setter  Property="BackgroundColor" Value="LightBlue" />
                            </VisualState.Setters>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateGroupList>
            </Setter>
        </Style>


    </ContentPage.Resources>

    <Grid>
        <CollectionView
            SelectionMode="Single"
            WidthRequest="300"
            HeightRequest="500"
            VerticalScrollBarVisibility="Never">

            <CollectionView.ItemsSource>
                <x:Array  Type="{x:Type x:Int32}">
                    <x:Int32>0</x:Int32>
                    <x:Int32>1</x:Int32>
                    <x:Int32>2</x:Int32>
                    <x:Int32>3</x:Int32>
                    <x:Int32>4</x:Int32>
                    <x:Int32>5</x:Int32>
                    <x:Int32>6</x:Int32>
                    <x:Int32>7</x:Int32>
                    <x:Int32>8</x:Int32>
                    <x:Int32>9</x:Int32>
                    <x:Int32>10</x:Int32>
                    <x:Int32>20</x:Int32>
                    <x:Int32>30</x:Int32>
                    <x:Int32>40</x:Int32>
                    <x:Int32>50</x:Int32>
                    <x:Int32>60</x:Int32>
                    <x:Int32>70</x:Int32>
                    <x:Int32>80</x:Int32>
                    <x:Int32>90</x:Int32>
                </x:Array>
            </CollectionView.ItemsSource>

            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Frame Padding="8" x:Name="myframe">
                        <Label FontSize="14" VerticalOptions="Center" TextColor="red" HorizontalOptions="Center" Text="{Binding}"/>
                    </Frame>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>

    </Grid>

</ContentPage>

windows screen
image

android selected item not hihglighted

image

Steps to Reproduce

copy pase my code

Link to public reproduction project repository

https://github.com/KWodarczyk/MauiBugs/tree/main/Bugs/MauiCollectionViewHighlightBug

Version with bug

7.0 (current)

Last version that worked well

6.0.312

Affected platforms

Android

Affected platform versions

Android

Did you find any workaround?

no

Relevant log output

No response

@KWodarczyk KWodarczyk added the t/bug Something isn't working label Mar 13, 2023
@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Mar 14, 2023
@TannerDBlack
Copy link

I have seen this issue as well. I can reload the entire list and it will work but this is terrible for performance.

For me it works in Debug but not Release builds.

@Zhanglirong-Winnie Zhanglirong-Winnie added the s/triaged Issue has been reviewed label Jun 21, 2023
@Zhanglirong-Winnie
Copy link
Collaborator

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. The layout has changed, so not sure if this issue is repro.
13885

Copy link
Contributor

Hi @KWodarczyk. 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.

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/windows 🪟 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants