How to display custom font in grid cell in MAUI DataGrid (SfDataGrid)?
The .NET MAUI DataGrid(SfDataGrid) allows you to display custom fonts in DataGridColumn. To use the custom fonts in SfDataGrid, refer to the following steps:
Step 1: Add the custom fonts in True Type Font (TTF) format in the Resources’ Fonts folder.
Step 2: Register the fonts by invoking the ConfigureFonts method on the MauiAppBuilder object. Add the required fonts using the AddFont method by passing the font filename as a parameter. You can also specify an optional alias name by passing the second parameter.
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.ConfigureSyncfusionCore(); return builder.Build(); } }
Step 3: Consume the fonts by referencing its name or alias name to the RowFontFamily property of DataGridStyle.
<syncfusion:SfDataGrid x:Name="dataGrid" AutoGenerateColumnsMode="None" GridLinesVisibility="Both" HeaderGridLinesVisibility="Both" ColumnWidthMode="Fill" ItemsSource="{Binding OrderInfoCollection}" > <syncfusion:SfDataGrid.DefaultStyle> <syncfusion:DataGridStyle RowFontSize="10" RowFontFamily="Satisfy-Regular"></syncfusion:DataGridStyle> </syncfusion:SfDataGrid.DefaultStyle> <syncfusion:SfDataGrid.Columns> <syncfusion:DataGridTextColumn MappingName="Customer" HeaderText="Name"> </syncfusion:DataGridTextColumn> <syncfusion:DataGridTextColumn MappingName="Country"></syncfusion:DataGridTextColumn> </syncfusion:SfDataGrid.Columns> </syncfusion:SfDataGrid>
View Sample on Github
Take a moment to pursue this documentation, where you will find more about Syncfusion .NET MAUI DataGrid(SfDataGrid) with code examples.
Please refer to this link to learn about the essential features of Syncfusion .NET MAUI DataGrid(SfDataGrid).
Conclusion
I hope you enjoyed learning about how to perform CRUD operations in MAUI DataGrid (SfDataGrid).
You can refer to our .NET MAUI DataGrid’s feature tour page to know about its other groundbreaking feature representations. You can also explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our .NET MAUI DataGrid and other .NET MAUI components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac or feedback portal. We are always happy to assist you!