I have a custom renderer that I'm using for Android, and I'm linking to the Control.ViewTreeObserver's .PreDraw event.
That seems to work great, however when it comes to cleaning up that event reference ViewTreeObserver's .PreDraw -= doesn't seem to remove the event.
After popping the view that was using the custom renderer I still get "PreDraw Fired" popping up in logging. If I re-enter the view with the custom renderer, I then get "PreDraw Fired" 2x as much, and it continues to increase as I leave/re-enter (See pseudo code below)
I've also tried this with AddOnPreDrawListener and RemoveOnPreDrawListener.
Any ideas? Thanks!
OnElementChanged(...) {
...
var vto = Control.ViewTreeObserver;
vto.PreDraw += Event_PreDraw;
}
Event_PreDraw (...) {
Console.WriteLine("PreDraw Fired");
}
Dispose (...) {
var vto = Control.ViewTreeObserver;
vto.PreDraw -= Event_PreDraw;
}