How to set Grid fontFamily and size to Static Reource

Hi,

How to set the font family and font size of the entiry DataGrid to a static resource??

I have this static recource:
  <OnPlatform
                x:Key="FontFamilyName"
                x:TypeArguments="x:String"
                Android="OpenSans-Regular.ttf#Regular"
                iOS="ProximaNova-Regular.otf#Regular" />
 <Style x:Key="ChatTypeFont" TargetType="Label">
                <Setter Property="FontFamily" Value="{StaticResource CharListFont}" />
                <Setter Property="FontSize">
                    <Setter.Value>
                        <OnPlatform
                            x:TypeArguments="x:Double"
                            Android="16"
                            iOS="12" />
                    </Setter.Value>
                </Setter>
                <Setter Property="TextColor" Value="Black" />
            </Style>

How to use it with the DataGrid?

Thank you

2 Replies 1 reply marked as answer

CS Chandrasekar Sampathkumar Syncfusion Team February 21, 2021 06:08 PM UTC

Hi Helder, 
Thank you for using Syncfusion products. 
Currently, we are checking on the reported issue How to set Grid font family and size to Static Resource. We will validate and update further details on or before February 23, 2021. We appreciate your patience until then. 
Regards, 
Chandrasekar Sampathkumar 



CS Chandrasekar Sampathkumar Syncfusion Team February 23, 2021 06:22 PM UTC

Hi Helder, 
Thank you for your patience. 
We have checked the reported query “How to set DataGrid font family and size from Static Resource” from our end. You can achieve your requirement by setting static resource to RecordFont and CellTextSize for each column. Please refer the following code snippets to achieve your requirement, 
Xaml: Setting Font family and size 
<ContentPage.Resources> 
    <OnPlatform 
            x:Key="FontFamilyName" 
            x:TypeArguments="x:String" 
            Android="OpenSans-Regular.ttf" 
            iOS="Samantha.ttf" /> 
    <OnPlatform 
        x:Key="GridFontSize" 
            x:TypeArguments="x:Double" 
            Android="16" 
            iOS="12" /> 
</ContentPage.Resources> 
<StackLayout Orientation="Vertical"> 
    <sfgrid:SfDataGrid x:Name="sfGrid"  
                    AutoGenerateColumns="False" HeaderRowHeight="70" 
                    AllowSorting="True" 
                    ColumnSizer="Star" 
                    AllowDraggingRow="True" 
                    AllowResizingColumn="True" 
                    SelectionMode="Single" 
                    AllowEditing="True" 
                    NavigationMode="Cell" 
                    ItemsSource="{Binding OrdersInfo}" > 
        <sfgrid:SfDataGrid.Columns x:TypeArguments="syncfusion:Columns"> 
            <sfgrid:GridTextColumn HeaderText="Customer ID" LoadUIView="True" 
                                    MappingName="CustomerID"  
                                    HeaderFont="{StaticResource FontFamilyName}" 
                                    HeaderCellTextSize="{StaticResource GridFontSize}" 
                                    RecordFont="{StaticResource FontFamilyName}"  
                                    CellTextSize="{StaticResource GridFontSize}"/> 
        </sfgrid:SfDataGrid.Columns> 
    </sfgrid:SfDataGrid> 
</StackLayout> 
We have prepared simple sample based on your requirement and you can download the same using the following link, 
Sample Link: Sample 
Please let us know if you would require further assistance. 
Regards, 
Chandrasekar Sampathkumar 


Marked as answer
Loader.
Up arrow icon