maui
maui copied to clipboard
.NET MAUI - CollectionView SelectedItem binding functions on Windows but not Android platform
Description
CollectionView SelectedItem property binds to viewmodel property as expected on Windows platform. On Android platform clicking on an item of the CollectionView does not function as expected - the bound SelectedItem property is not activated. Please refer to the project 'MauiApp1' in Solution Folder 'CollectionView' of the solution at the following https://github.com/AndreduToit/NetMauiReproductions (reproduction sample code). Ensure ShellContent, ContentTemplate="{DataTemplate local:MainPage}".
Steps to Reproduce
- Please refer to the project 'MauiApp1' in Solution Folder 'CollectionView' of the solution at the following https://github.com/AndreduToit/NetMauiReproductions (reproduction sample code).
- Ensure ShellContent, ContentTemplate="{DataTemplate local:MainPage}".
- Run the project on Windows platform.
- Click the any item of the CollectionView - background color changes as expected.
- Run the same code on Android platform - background color DOES NOT change as expected.
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 11.0
Did you find any workaround?
One workaround is to add a TapGestureRecognizer to the CollectionView.ItemTemplate. Add an Action to the viewmodel of the CollectionView item and point it back to an Action in the main page viewmodel. Workaround is demonstrated with MainPage2 of the reproduction sample code mentioned above. Just change ContentTemplate="{DataTemplate local:MainPage} to ContentTemplate="{DataTemplate local:MainPage2} in file AppShell.xaml.
Relevant log output
None
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.
Related: https://github.com/dotnet/maui/pull/7689
The impact of this issue is clear and it is not a very corner case scenario. It is simple code which works as expected on one platform but not another. In my opinion it is a fundamental bug which requires a complete refactoring of all my .NET Maui code to implement a workaround - so that I may have a functioning app whilst waiting for a bug fix. It causes me to question (once again) whether .NET Maui should have GA status. Please fix the bug soon, it is not a feature request so please don't wait for upvotes, etc.
I ran into the same problem. I decided perhaps Maui is not mature enough especially with this obvious issue to make the switch so I'm going back to Xamarin forms for now.
Verified this issue with Visual Studio Enterprise 17.6.0 Preview 7.0. Repro on Android platform with sample project. Windows works fine.
NetMauiReproductions-master.zip
Android:
Windows:
It's crazy to me this still isn't prioritized or fixed after a year. This is table steaks
Do you have due date?
@AndreduToit and @chris-oswald are completly right, this bug is extremly annoying, since basically every application uses a collectionview. I would prioritize this bug way higher, since selecting an item from a list is basic functionallity of any ui framework.