Hi!
I wrote a custom PageRenderer based on CarouselPageRenderer (added tabs to it, so it is a swipable tabbedpage). The only problem I'm facing is the handling of the tabs.
I'm using the following events:
- OnElementChanged: used for populating the tab bar
- OnDetachedFromWindow: used for removal of the tab bar
- OnAttachedToWindow: used for the initialization of the tab bar
- OnVisibilityChanged: used for switching between pages of this type
However, it does not work as it should. The problem is, the ApplicationBar is not a per-Page property of App.Current.Context as Activity, but is a singleton, and thus, global. This would not be a big problem in itself, if Page events were not fired async.
A technical example:
Pages A and B are of the same type, this custom CarouselPage (lets call it CCarouselPage for now).
From the homescreen I open Page A, and it runs:
- OnElementChanged to populate the tab bar
- OnAttachedToWindow to enable the tab bar
It works fine and dandy. Then from Page A, I open Page B. This is what happens:
- OnElementChanged of Page B runs, populates the tab bar
- OnAttachedToWindow of Page B runs, (re)enabling the tab bar
- OnVisibilityChanged of Page A runs, disabling the tab bar
- OnDetachedFromWindow of Page A runs, disabling the tab bar again
Why is the event management so fuked up? Why can't it be a bit more linear, so events run when one would expect it?