MAUI CollectionView reuses custom control state (VoteControl) and does not reset when recycled. #33589
Replies: 1 comment 1 reply
-
|
This line in RootVoteControl.Vote = vm.VoteType;breaks/replaces the XAML binding Vote="{Binding VoteType}" |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
2026-01-19.00-01-49.mp4
I’m facing an issue with CollectionView virtualization / recycling in .NET MAUI where a custom control keeps its internal UI state when reused for different items.
🔍 Scenario
I have a custom control called VoteControl (similar to Reddit upvote/downvote) used inside a CollectionView item template.
The control has:
UpVoteCount (BindableProperty)
DownVoteCount (BindableProperty)
Vote (BindableProperty, enum: None / Up / Down)
Internal UI elements (ImageCheckBox(CustomControl))
The control is bound like this:
❌ Problem
When scrolling the CollectionView:
If I upvote or downvote one item
Scroll down so the item is recycled
The same VoteControl instance appears again
It retains the previous checked state (up/down) instead of resetting based on the new BindingContext
So the UI shows wrong vote state for different items.
This happens repeatedly while scrolling.
when bindingContext Change i apply the VoteType Directly To UI using x:name it is working fine, but the OnBindingContextChanged() Method was Frequently Triggering when scroll the CollectionView and the app not feel smoot.
Beta Was this translation helpful? Give feedback.
All reactions