)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create SfTabView using Custom FontIcon

Platform: Xamarin.Forms |
Control: SfTabView |
Published Date: November 19, 2018 |
Last Revised Date: June 21, 2019

You can use the Font icon on SfTabView header using the following steps:

 

Step 1: Add the necessary assemblies in the PCL, Android, iOS, and UWP projects. Refer to this UG documentation to know more about the assemblies required for adding SfTabView  to your project.

 

Step 2: Add the necessary font ttf files on the respective project.

 

Add the following XAML code for adding the Font icon to all the platforms.

XAML:

<ContentPage.Resources>
        <ResourceDictionary>
            <OnPlatform x:TypeArguments="x:String" x:Key="fontFamily" iOS="TabView" Android="TabView.ttf" WinPhone="TabView#TabView.ttf" />
        </ResourceDictionary>
    </ContentPage.Resources>

 

 

Add the following code sample to add the SfTabView control with Font ttf on header.

<ContentPage.Content>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />            
        </Grid.RowDefinitions>
        <SyncfusionTabView:SfTabView x:Name="ZayedTabView" Grid.Row="1" DisplayMode="Image" TabHeaderPosition="Bottom" EnableSwiping="false" VisibleHeaderCount="5">
        <SyncfusionTabView:SfTabItem x:Name="tabHome" Title="A" FontIconFontFamily="{StaticResource fontFamily}" IconFont="C">
                     <SyncfusionTabView:SfTabItem.Content>
                    <Grid BackgroundColor="White" x:Name="AllContactsGrid" >
                        <ListView x:Name="ContactListView" 
                                  ItemsSource="{Binding ContactList}"
                                  RowHeight="75">
                            <ListView.BindingContext>
                                <local:ContactsViewModel />
                            </ListView.BindingContext>
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                        <StackLayout Orientation="Vertical" Margin="30,0,0,0">
                                            <Label 
                                                Text="{Binding Name}"
                                                FontSize="24" 
                                                 />
                                            <Label 
                                                Text="{Binding Number}" 
                                                FontSize="20" 
                                                TextColor="LightSlateGray" />
                                        </StackLayout>
                                    </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>
                    </Grid>
                </SyncfusionTabView:SfTabItem.Content>
                    </SyncfusionTabView:SfTabItem>
        <SyncfusionTabView:SfTabItem x:Name="tabNews" Title="B" FontIconFontFamily="{StaticResource fontFamily}" IconFont="B" >
                    <SyncfusionTabView:SfTabItem.Content>
                    <Grid BackgroundColor="White" x:Name="AllContactsGrid1" >
                        <ListView x:Name="ContactListView1" 
                                  ItemsSource="{Binding ContactList}"
                                  RowHeight="75">
                            <ListView.BindingContext>
                                <local:ContactsViewModel />
                            </ListView.BindingContext>
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                        <StackLayout Orientation="Vertical" Margin="30,0,0,0">
                                            <Label 
                                                Text="{Binding Name}"
                                                FontSize="24" 
                                                 />
                                            <Label 
                                                Text="{Binding Number}" 
                                                FontSize="20" 
                                                TextColor="LightSlateGray" />
                                        </StackLayout>
                                    </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>
                    </Grid>
                </SyncfusionTabView:SfTabItem.Content>
                    </SyncfusionTabView:SfTabItem>
        <SyncfusionTabView:SfTabItem x:Name="tabNew"  Title="C" FontIconFontFamily="{StaticResource fontFamily}" IconFont="D" />
        <SyncfusionTabView:SfTabItem x:Name="tabNotifications" Title="D" FontIconFontFamily="{StaticResource fontFamily}" IconFont="E" />
       
        </SyncfusionTabView:SfTabView>
    </Grid>
    </ContentPage.Content>

 

Output image

Creating SfTabView using custom font icon

 

Please find the sample from this link.

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon