Fixed #56 in MAUI. I don't know if the leak exists in Xamarin.Forms or not.
On iOS in MAUI, it's necessary to call DisconnectHandler() to prevent the CollectionView from leaking. This is a big issue since the leak will cascade through the .Parent property to the containing page and prevent it from being garbage collected.
This PR introduces a new BindableProperty on the CollectionView AutoDisconnectHandler, which is true by default and will call DisconnectHandler() during the Unload event.
I added the bindable property because, while automatically disconnecting the handler on unload is what most developers will want 99% of the time, you may not want this if the CollectionView is intentionally being temporarily removed from the main object tree. In these cases, the bindable property allows developers to opt out of this automatic behavior and assume responsibility for calling DisconnectHandler() themselves.
Fixed #56 in MAUI. I don't know if the leak exists in Xamarin.Forms or not.
On iOS in MAUI, it's necessary to call
DisconnectHandler()
to prevent the CollectionView from leaking. This is a big issue since the leak will cascade through the .Parent property to the containing page and prevent it from being garbage collected.This PR introduces a new BindableProperty on the CollectionView
AutoDisconnectHandler
, which is true by default and will callDisconnectHandler()
during theUnload
event.I added the bindable property because, while automatically disconnecting the handler on unload is what most developers will want 99% of the time, you may not want this if the CollectionView is intentionally being temporarily removed from the main object tree. In these cases, the bindable property allows developers to opt out of this automatic behavior and assume responsibility for calling
DisconnectHandler()
themselves.