CarouselView Renders Duplicate Data Templates Multiple Times
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
When running the Maui Samples, the `CarouselView` renders `Monkey` instances multiple times. In `MonkeysViewModel.CreateMoneyCollection` the code is loading 17 `Monkey` objects into `Monkeys`, an `ObservableCollection` of `Monkey`. However, the `CarouselView` is showing many more items than 17, duplicating the original 17 multiple times. Here's the URL to the solution in the `maui-samples` repository:
https://github.com/dotnet/maui-samples/tree/main/6.0/UserInterface/Views/CarouselViewDemos
I ran into this problem with my code and verified that it reproduces with the `maui-samples` solution too.
### Steps to Reproduce
1. Clone `maui-samples`
2. Run the carousel demo at https://github.com/dotnet/maui-samples/tree/main/6.0/UserInterface/Views/CarouselViewDemos
3. Select Horizontal Data Template
4. Observe the duplicated templates.
### Link to public reproduction project repository
https://github.com/dotnet/maui-samples/tree/main/6.0/UserInterface/Views/CarouselViewDemos
### Version with bug
7.0 (current)
### Last version that worked well
Unknown/Other
### Affected platforms
Windows
### Affected platform versions
10.0.17763.0
### Did you find any workaround?
_No response_
### Relevant log output
_No response_
Contributor guide
Research direction
Start by running the linked maui-samples CarouselViewDemos project on Windows and selecting Horizontal Data Template. Inspect MonkeysViewModel.CreateMoneyCollection and the CarouselView data-template setup; done means the 17 Monkey objects render once rather than appearing duplicated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100