Repository navigation
Description
Description
When items are removed from a CollectionView, or when a DataTemplateSelector switches templates (making certain item templates no longer active), the handlers for controls within those templates are not properly disconnected. This results in memory leaks as the controls and their handlers remain in memory.
Scenario 1: DataTemplateSelector switching templates
- Create a
CollectionViewwith aDataTemplateSelectorthat switches between two templates based on item state - Initially render some items with Template A
- Change the item state so all items now use Template B (Template A is no longer used)
- Observe that handlers for controls in Template A instances remain connected
Scenario 2: Removing items from CollectionView
- Create a
CollectionViewwith items - Remove items from the
ObservableCollection(usingRemoveAt(),Remove(), orClear()) - Observe that handlers for controls in the removed items remain connected
Expected Behavior
When a CollectionView item is removed or its template is no longer used, all handlers for controls within that item's template should be automatically disconnected via OnHandlerChanged() being called with a null handler.
Actual Behavior
Handlers remain connected indefinitely. The controls remain in memory and cannot be garbage collected, leading to memory leaks. Only recently created items have their handlers disconnected; older items keep their handlers connected.
Steps to Reproduce
- Clone https://github.com/Vetle444/MauiTestApp/tree/collectionViewItemHandler
- Make sure to be on branch collectionViewItemHandler
- Build and deploy app
- Navigate to
CollectionView Template Handler Test - Click "Switch to all Template B"
- Navigate back
- Click
Show Labels With Connected Handlers - Observe that the items that were removed did not have their handler disconnected
Link to public reproduction project repository
https://github.com/Vetle444/MauiTestApp/tree/collectionViewItemHandler
Version with bug
9.0.110 SR12
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
No response
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
Some way to disconnect it manually

Activity
TamilarasanSF4853 commentedon Oct 28, 2025
This issue has been validated in Visual Studio Code 1.105.1 with MAUI versions 9.0.0, 9.0.110 and 9.0.120. It can be reproduced on Android platform.
[Android, Windows] Fix CollectionView handler cleanup when DataTempla…
6 remaining items
[Android] Fix CollectionView scrolling performance regression (#35379)
sheiksyedm commentedon Jul 7, 2026
This issue fix reverted due to regressions. Therefore, reopen this.