Carousel not changing items in real-time, blank slide, grey bar at the bottom on iOS

Reza Mohamed 1 Reputation point
2024-05-29T19:06:17.7066667+00:00

I am binding an ObservableCollection to a Carousel view and displaying images and text. What I am noticing is that if I change the contents of the ObservableCollection, the Carousel doesn't reflect the change in realtime. I have to swipe through a few items and only then does the item change. I cant figure out if this is a bug in my code or MAUI. This exact code worked just fine in Xamarin. I have created a sample repo here: https://github.com/rezamohamed/CarouselBinding

(1) When I press the button, I expect the Text to change (I have also tried this with the image and get the same faulty behavior). The text only changes after I swipe across and return to that same slide.

On iOS - the change can be seen after a few swipes. On Android, the change is never seen.

https://i.sstatic.net/wO3EK9Y8.png

(2) some of the slides won't show the image or the text when you swipe through On iOS - this issue is prevalent. On Android - not seeing this issue

https://i.sstatic.net/pBFe4dnf.png

(3) There is a grey bar that appears on swipe that randomly shows up at the bottom (directly above the indicator), how do I get rid of that? On iOS - this issue is prevalent. On Android - not seeing this issue

https://i.sstatic.net/lQbKCe79.png

Developer technologies | .NET | .NET MAUI
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2024-05-30T09:50:19.12+00:00

    Hello,

    There is a duplicate thread on SO - MAUI Carousel not changing items in real-time, blank slide, grey bar at the bottom on iOS - Stack Overflow)

    Please make CarouselData implement ObservableObject using MVVM communitytoolkit. That'll update the UI automatically after changing the Text value: Data[0].Text = "CHANGED".

    public partial class CarouselData : ObservableObject
    {
        public ImageSource Image { get; set; }
    
        [ObservableProperty]
        public string? _text;
    }
    

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.