protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            if (this.pagerPage == null)
            {
                this.pagerPage = new ViewPagerPage() { FragmentManager = this.FragmentManager };
                this.visualRoot.Child = pagerPage;
            }

            // this will start Navigation to first tab
            this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

            var styledAttributes = this.Theme.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.ActionBarSize, Android.Resource.Attribute.ActionBarStyle });
            var mActionBarSize = (int)styledAttributes.GetDimension(0, 0);
            var actionbarStyleId = styledAttributes.GetResourceId(1, 0);
            styledAttributes.Recycle();

            styledAttributes = this.Theme.ObtainStyledAttributes(actionbarStyleId, new int[] { Android.Resource.Attribute.BackgroundStacked });
            var tabsBackground = styledAttributes.GetDrawable(0);
            styledAttributes.Recycle();

            rootLayout = new RootLayout(this);

            this.rootLayout.SetBackgroundDrawable(tabsBackground);

            rootLayout.SetPadding(0, mActionBarSize, 0, 0);
            this.Window.DecorView.RootView.ViewTreeObserver.AddOnGlobalLayoutListener(this);

            frameLayout = new FrameLayout(this);
            frameLayout.Id = this.fragmentPageFrameLayoutResourceId;
            frameLayout.Visibility = ViewStates.Gone;
            rootLayout.SizeChanged += (s, e) => UpdateRootLayouts();
            this.pagerPage.ViewPager.LayoutChange += ViewPagerLayotChange;

            this.pagerPage.ViewPager.PageSelected += Pager_PageSelected;

            rootLayout.AddView(this.pagerPage.ViewPager, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
            rootLayout.AddView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));

            this.SetContentView(rootLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
        }
        private void Tabs_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
                case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                    var tab = e.NewItems[0] as TabBarTab;
                    var androidTab = ActionBar.NewTab();

                    if (!string.IsNullOrEmpty(tab.Title))
                    {
                        androidTab.SetText("  " + tab.Title);
                    }
                    if (tab.Icon != null)
                    {

                        if (tab.Icon.ImageLoadStatus == Media.ImageStatus.Loaded)
                        {
                            androidTab.SetIcon(new BitmapDrawable(tab.Icon.GetBitmap()));
                        }
                        else
                        {
                            tab.Icon.ImageOpened += (s, ea) => androidTab.SetIcon(new BitmapDrawable(tab.Icon.GetBitmap()));
                        }
                    }

                    androidTab.TabSelected += TabSelected;
                    this.ActionBar.AddTab(androidTab, e.NewStartingIndex);
                    if (this.pagerPage == null)
                    {
                        this.pagerPage = new ViewPagerPage() { FragmentManager = this.FragmentManager };
                        this.visualRoot.Child = pagerPage;
                    }
                    var page = this.InstantiatePage(tab.PageType);
                    page.NavigationService = this.navigationService;
                    this.pagerPage.AddPage(page, tab.NavigationParameter);
                    break;
                case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                    break;
                case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                    break;
                default:
                    throw new InvalidEnumArgumentException();
            }
        }