Why can't I override the XF Android TabbedPage renderer?

uwantfriesuwantfries ✭✭GBBeta ✭✭

Why can't I override the XF Android TabbedPage renderer?
I am using the newer AppCompatActivity but when I try to override the TabbedPage I see no tabs? The minimal renderer below kills my tabs.

using Xamarin.Forms;
using AdvancedForms.Droid.CustomRenderer;
using Xamarin.Forms.Platform.Android;
using Android.Graphics.Drawables;
using Android.App;

using System;
using Android.Graphics;
using Android.Widget;
using Android.Content;

[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTab))]
namespace AdvancedForms.Droid.CustomRenderer
{
    public class CustomTab : TabbedRenderer
    {

        public CustomTab(Context ctx) : base(ctx)
        {

        }

        protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
        {
            base.OnElementChanged(e);

        }
    }
}

Answers

  • WarwenczackWarwenczack ✭✭ BRMember ✭✭
  • uwantfriesuwantfries ✭✭ GBBeta ✭✭

    Thanks for the link but I think I may be missing something as I cannot seem to work out what I am doing wrong from that.

    The test case here (https://github.com/xamarin/Xamarin.Forms/issues/1462 - not that I can run it as I am on VS2015) seems to be very similar and I have a tabbar.axml that seems to work when as long as I don't override it, but as soon as I introduce the above code no tabs are displayed.

  • WarwenczackWarwenczack ✭✭ BRMember ✭✭

    Can u post the code ?

  • uwantfriesuwantfries ✭✭ GBBeta ✭✭

    Always annoying to reply to your own thread but the problem with the above seems to be that I was overriding the wrong class :(

    it should be Xamarin.Forms.Platform.Android.AppCompat.TabbedPageRenderer NOT TabbedRenderer eg

    public class CustomTab : Xamarin.Forms.Platform.Android.AppCompat.TabbedPageRenderer

Sign In or Register to comment.