Skip to content

Cannot preselect items in CollectionView when it's multiselect on Windows, iOS and macOS #15718

Open

Description

Description

Using a CollectionView it is not possible to preselect items when mode is set to "multiple". It doesn't work on Windows, iOS or macOS however it does work on Android.

Using the method described here: https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/collectionview/selection#multiple-preselection
Multiple preselection does not work.

No items in the collection view are pre selected even though the collection in the view model does have the correct values.

I cannot find a way to preselect items in the CollectionView on Windows, iOS or macOS. The only way I can find to select items programmatically from the view model is by using the UpdateSelectedItems method and that only seems to work when triggered manually from a button. It does not work in the constructor or even when used in the onAppearing method.

Steps to Reproduce

  1. Follow the steps described in the following article to set up a collection view and populate it with preselection in a view model
    https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/collectionview/selection#multiple-preselection
  2. Run the solution and observe the items are not pre selected on Windows, iOS or macOS. However they are preselected on Android.

Use the attached example solution.

  1. Run the solution.
  2. Observe that the items are not pre-selected when the app is first executed, on Windows, iOS and macOS.
  3. Click the button labelled "Select using Binding" and observe the items are NOT selected.
  4. Click the button labelled "Select using Method" and observe the items ARE selected.

Link to public reproduction project repository

https://github.com/KeithBoynton/CollectionView

Version with bug

7.0.49

Last version that worked well

Unknown/Other

Affected platforms

iOS, Windows, macOS

Affected platform versions

Latest

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions