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.27k stars 1.76k forks source link

[Regression from Xamarin Forms] CarouselView does not update view when current item changes programmatically #12915

Open mfeingol opened 1 year ago

mfeingol commented 1 year ago

Description

I have a CarouselView bound to some items. I have a control outside the CarouselView that changes the selected item on the page's ViewModel. Everything works fine in Xamarin.Forms. With .NET Maui the CarouselView does not update its view when I change the selected item programmatically.

However, it does work once I've manually swiped the CarouselView left (once) to change the selected item. After I do that, changing the CarouselView item programmatically works fine. This looks to be a CarouselView bug.

NB: I've tried setting CurrentItem directly on the CarouselView as well as updating ViewModel.SelectedItem. Neither of these work at first.

Steps to Reproduce

Please run the repro project and observe that, on Android, pressing the "switch" button does nothing until the carousel is swiped manually, once. It should work from the start without issues.

Link to public reproduction project repository

https://github.com/mfeingol/repros/tree/master/CarouselViewRepro

Version with bug

7.0 (current)

Last version that worked well

7.0 (current)

Affected platforms

Android

Affected platform versions

Android 13

Did you find any workaround?

No response

Relevant log output

No response

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.

mfeingol commented 1 year ago

@jsuarezruiz: any thoughts on how to work around this? It leads to a fairly blocking issue in my app, which I'm actively attempting to port to Maui.

noque-lind commented 1 year ago

We are hit by this same issues. Would love to know if someone found a workaround to it.

minglu commented 1 year ago

Following

noque-lind commented 1 year ago

I have worked around this issue by setting Loop to true - because I'm not allowing my users to swipe I can still make sure they do not loop the carousel view. But now it is possible to update the carouselView in code.

mfeingol commented 1 year ago

Out of curiosity, what did you do to disable swiping?

EwaldJebaraj commented 1 year ago

Any update on this

XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.7.0 Preview 2.0. This issue does not repro on iOS 16.4. repro on Android 13.0-API33 with below Project: CarouselViewRepro.zip

RobTF commented 1 year ago

+1 hit this

echolumaque commented 1 year ago

I have worked around this issue by setting Loop to true - because I'm not allowing my users to swipe I can still make sure they do not loop the carousel view. But now it is possible to update the carouselView in code.

This works for the meantime. But as usual, MSFT messes up us again big time :). I'm not even surprised because lots of problems specially on CollectionView on Xamarin days.

aschuhardt commented 1 year ago

Note for others running into this that due to #7000 the Loop = true workaround may break things in other ways.

mfeingol commented 12 months ago

This appears to be fixed in the current version of .NET Maui - 8.0.3.

cmartinezcxm commented 6 months ago

I'm using .Net Maui 8.0.3 and I still get that crash