Forum Xamarin.Forms

How can I use Xamarin.Forms.Platform.UWP.TabbedPageRenderer ? No method to override!

PhilipOGormanPhilipOGorman USMember ✭✭✭

I am trying to create a renderer for a tabbed page. When I look at TabbedPageRenderer, there is nothing to override :

`namespace Xamarin.Forms.Platform.UWP
public class TabbedPageRenderer : IVisualElementRenderer, IRegisterable, IDisposable, ITitleProvider
public TabbedPageRenderer();

    public FrameworkElement ContainerElement { get; }
    public Pivot Control { get; }
    public TabbedPage Element { get; }
    protected VisualElementTracker<Page, Pivot> Tracker { get; set; }

    public event EventHandler<VisualElementChangedEventArgs> ElementChanged;

    public void Dispose();
    public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint);
    public void SetElement(VisualElement element);
    protected virtual void Dispose(bool disposing);
    protected void OnElementChanged(VisualElementChangedEventArgs e);


The usual method gives an error:
public class CustomTabRenderer : TabbedPageRenderer { protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); } }

what can I do here?

Best Answer


  • PhilipOGormanPhilipOGorman USMember ✭✭✭

    with a liitle help from here

    I got it to work:

    ` public class CustomTabRenderer : TabbedPageRenderer
    public CustomTabRenderer()
    this.ElementChanged += CustomTabRenderer_ElementChanged;

        private void CustomTabRenderer_ElementChanged(object sender, VisualElementChangedEventArgs e)
            Control.HeaderTemplate = GetStyledTitleTemplate();
        private Windows.UI.Xaml.DataTemplate GetStyledTitleTemplate()
            string dataTemplateXaml = @"<DataTemplate xmlns=""""
                        FontFamily=""Segoe UI""
                        FontSize=""90"" />
            return (Windows.UI.Xaml.DataTemplate)XamlReader.Load(dataTemplateXaml);
  • When I use this, there is a Parsing Exception in XamlReader.Load(dataTemplateXaml)

Sign In or Register to comment.