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

CarouselPage with Tabs *almost* working on Android

$
0
0

Hello,

I created a custom CarouselPage renderer that adds a tabbed navigation on top of the carousel, so that the pages can be navigated by either swiping or by clicking the tabs. Now it works perfectly, except for one (pretty important) thing: when I navigate to a sub page (which is a TabbedPage and has its own, native tab bar) and then come back, the tab bar is nowhere to be seen.

The tab bar is made in the "OnElementChanged" event. The pages are loaded asynchronously, so I create a "Element.ChildAdded" handler that adds a new tab into the tab bar every time a new Child is added to the CarouselPage.

This ChildAdded handler isn't obviously being called when returning to the page (as the CarouselPage's children are already loaded), so I thought of adding a separate method in the "OnVisibilityChanged" event. So when the visibility is ViewStates.Visible and Element.Children.Count > 1 (e.g. the children have been loaded) I tried creating the tabs in a foreach loop. When I do this, for a brief moment the tab bar is visible. It contains the tabs from the subpage and the tabs the CarouselPage should have. But in a fraction of a second it disappears.

So. What am I doing wrong?


Viewing all articles
Browse latest Browse all 91519

Trending Articles