Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Removing Tap Handler

$
0
0

I have a question on memory management, specifically the correct way to remove the Tapped eventhandler for the TapGestureRecognizer.

In this sample here: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/gestures/

the handler is declared inline as an anonymous method...

but what happens when the view goes out of scope such as the item is tapped and the app loads another view? that handler remains attached, so the Visualelement to which it is attached will not be GC'd.

On relaunch of the view, would it not then make a new instance and therefore a new handler, increasing the memory load?

If so, what is the best practice to remove this handler? Is there a way for a VisualElement to detect that it is out of view so I can fire a method to remove the handler?

memory management isn't my area of expertise so please let me know if I'm completely misunderstanding how this works, thanks!


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>