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.21k stars 1.75k forks source link

Multiselection for Collectionview doesn't works on MacCatalyst #18028

Open bastiH96 opened 1 year ago

bastiH96 commented 1 year ago

Description

I found a report about this issue from november but the ticket got closed and i couldn't comment under it. https://github.com/dotnet/maui/issues/11023#issue-1430607779

The issue that happens is, that when I change the SelectionMode="Multiple" of a collectionview I'm only able to select a single item at a time, as if the SelectionMode would have been set to Single. This issue only happens on macCatalyst. I ran the exact same program on iOs and was able to select multiple items.

Steps to Reproduce

  1. Create .NET MAUI App
  2. copy / paste this collectionview into your MainPage:
    <CollectionView
                SelectionMode="Multiple">
                <CollectionView.ItemsSource>
                    <x:Array
                        Type="{x:Type x:String}">
                        <x:String>Apples</x:String>
                        <x:String>Banana</x:String>
                        <x:String>Cherry</x:String>
                    </x:Array>
                </CollectionView.ItemsSource>
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <VerticalStackLayout>
                            <Label
                                Text="{Binding .}"/>
                        </VerticalStackLayout>
                    </DataTemplate>
                </CollectionView.ItemTemplate>
            </CollectionView>
  3. Run the project on MacCatalyst and try to select multiple items in the collectionview.

-> you will only be able to select one item at the time, but you are supposed to select multiple items. If you run the exact same code on iOs, Android or Windows, it will work as expacted

Link to public reproduction project repository

No response

Version with bug

7.0.96

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

XamlTest commented 11 months ago

Verified this on Visual Studio Enterprise 17.9.0 Preview 1(8.0.3). Repro on MacCatalyst, not repro on Windows 11, Android 14.0-API34 and iOS 17.0 with below Project: 18028.zip

torfluor commented 4 months ago

Is there any workaround for this issue?

torfluor commented 4 months ago

It looks like this is a Mac Catalyst issue. According to this Stackoverflow thread both UITableView and UICollectionView require the user to hold down the COMMAND key to select multiple rows on Mac Catalyst. I have verified that by holding down the COMMAND key I'm able to select multiple rows in a MAUI CollectionView on Mac Catalyst.

So the question for the MAUI team is then; Do you want to fix this so MAUI CollectionView behave the same way on all platforms or do you want the behaviour to be platform specific as it is today?