Home

Awesome

NuGet

<img src="./nuget/ElegantTabs.png" width="100">

ElegantTabs for Xamarin.Forms

Elegant Tabs adds some of nifty features that are missing in Xamarin Forms Tabbed Pages

Note

Supported Platforms

How to Use?

Setup

Available on NuGet: http://www.nuget.org/packages/ElegantTabs. Install into your PCL/NETStandard project and Client projects

You have to register the custom renderer. You canput this in the AssemblyInfo.cs file of my Platform specific project (iOS, Android) csproj.

[assembly: ExportRenderer(typeof(TabbedPage), typeof(ElegantTabs.Droid.ElegantTabRenderer))]

NOTE: Custom TabbedPage / Custom Renderers

If you are using a custom renderer for TabbedPage please change it to inherit from ElegantTabRenderer and you are all set. Of course dont forget to register your own renderer.

In Tabbed Page XAML, add

xmlns:plugin="clr-namespace:ElegantTabs.Abstraction;assembly=ElegantTabs.Abstraction"

In any tab childrens you can add the following properties

PropertyType
IconstringOriginal Xamarin.Forms property. Compulsory if you want to display Icon
plugin:Transforms.SelectedIconstringIcon file source when tab is selected
plugin:Transforms.KeepIconColourIntactboolIf true, use the original file for icon without any extra tinting.
plugin:Transforms.DisableLoadboolTo avoid navigation / loading the page (suitable for popups)
plugin:Transforms.HideTitleboolTo remove or ignore title, and center the icon

Events

EventUsage
Transforms.TabIconClickedSubscribe to get icon click. Can be used from anywhere in the project (including tabbed page's code behind or viewmodel)

eg.

<?xml version="1.0" encoding="UTF-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            x:Class="Demo.Views.HomePage"
            xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
            android:TabbedPage.ToolbarPlacement="Bottom"
            android:TabbedPage.IsSwipePagingEnabled="False"
            android:TabbedPage.BarSelectedItemColor="{StaticResource AppOrangeColor}"
            xmlns:plugin="clr-namespace:ElegantTabs.Abstraction;assembly=ElegantTabs.Abstraction">

    <TabbedPage.Children>
       <ContentPage Icon="base.png" plugin:Transforms.SelectedIcon="base_selected.png" Title="Base" />
       <ContentPage Icon="quickbook.png"  plugin:Transforms.HideTitle="True" plugin:Transforms.DisableLoad="True" plugin:Transforms.KeepIconColourIntact="True"/>
       <ContentPage Icon="settings.png" plugin:Transforms.HideTitle="True" />
     </TabbedPage.Children>
</TabbedPage>

DISCLAIMER

This is a prerelease, I have not tested many cases like adding tabs dynamically, changing properties from view model, etc. I don't guarantee the performance and code quality of this library, this is an experimentation and all are welcome to send PR for improving performance or finding more simplified ways to solve this problem

Heavily inspired from Xamarin Forms source code and xamarin-forms-tab-badge.