Articles in this section
Category / Section

How to set custom font for items loaded in .NET MAUI ListView (SfListView) ?

3 mins read

The .NET MAUI ListView (SfListView) provides the capability to enhance item appearance using custom fonts. This guide outlines the steps to implement custom fonts in SfListView.

STEP 1: Add the custom fonts in True Type Font (TTF) format within the Resources’ Fonts folder.

STEP 2: Register these fonts in your application by invoking the ConfigureFonts method on the MauiAppBuilder object. Use the AddFont method to specify the font filename and an optional alias.

public static class MauiProgram
{
 public static MauiApp CreateMauiApp()
 {
  var builder = MauiApp.CreateBuilder();
  builder
   .UseMauiApp<App>()
   .ConfigureFonts(fonts =>
   {
    fonts.AddFont("Lobster-Regular.ttf", "LobsterRegular");
    fonts.AddFont("Satisfy-Regular.ttf", "SatisfyRegular");
   });
 
  builder.ConfigureSyncfusionListView();
  return builder.Build();
 }
}

STEP 3: Refer to the font name or alias using the FontFamily property within your XAML to apply the fonts.

<listView:SfListView x:Name="listView" ItemsSource="{Binding BookInfo}" ItemSize="120">
    <listView:SfListView.ItemTemplate>
        <DataTemplate>
            <StackLayout>
                <StackLayout Margin="10,0,0,0" VerticalOptions="StartAndExpand">
                    <Label Text="{Binding BookName}" FontFamily="Lobster-Regular" FontSize="20" VerticalOptions="CenterAndExpand"/>
                    <Label Text="{Binding BookDescription}" FontFamily="Satisfy-Regular" FontSize="20" VerticalOptions="StartAndExpand"/>
                </StackLayout>
                <BoxView HeightRequest="1" BackgroundColor="LightGray"/>
            </StackLayout>
        </DataTemplate>
    </listView:SfListView.ItemTemplate>
</listView:SfListView>
Output


Custom fonts in .NET MAUI ListView (SfListView)


Download the complete sample on GitHub.

Conclusion

I hope you enjoyed learning how to set a custom font for items loaded in .NET MAUI ListView.

You can refer to our .NET MAUI ListView feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. Explore our .NET MAUI ListView example to understand how to create and manipulate data.

For current customers, check out our components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our other controls.

Please let us know in the comments section if you have any queries or require clarification. Contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied