You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
I've spent several days trying to figure this out and I've not had much luck.
I have a page with a ListView whose ItemsSource is an ObservableCollection and uses a DataTemplateSelector. (I have 6 or 7 DataTemplates, each inherit from ViewCell).
As you can click on some buttons on the page, the ObservableCollection is cleared and then repopulated with different items, the UI reflects the changes and it all works perfectly fine.
The problem is: The more times the list is cleared and updated, the more leaks/zombies I get when I close the page. The leaks are coming from the DataTemplates of all of the items that were loaded and cleared since the page was opened.
I understand that I cannot add the TearDownBehavior to the DataTemplates because they are ViewCells, which are Elements, not VisualElements.
I've tried creating a CustomViewCell class and overriding OnDisappearing() and OnChildRemoved() to see if I could clean things up at either of those points, but that wasn't working.
Any thoughts or suggestions?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi.
I've spent several days trying to figure this out and I've not had much luck.
I have a page with a ListView whose ItemsSource is an ObservableCollection and uses a DataTemplateSelector. (I have 6 or 7 DataTemplates, each inherit from ViewCell).
As you can click on some buttons on the page, the ObservableCollection is cleared and then repopulated with different items, the UI reflects the changes and it all works perfectly fine.
The problem is: The more times the list is cleared and updated, the more leaks/zombies I get when I close the page. The leaks are coming from the DataTemplates of all of the items that were loaded and cleared since the page was opened.
I understand that I cannot add the TearDownBehavior to the DataTemplates because they are ViewCells, which are Elements, not VisualElements.
I've tried creating a CustomViewCell class and overriding OnDisappearing() and OnChildRemoved() to see if I could clean things up at either of those points, but that wasn't working.
Any thoughts or suggestions?
Beta Was this translation helpful? Give feedback.
All reactions