Changing the font size on selection

we have the requirement that on selection the font size, fontweight and maybe even font family should be changed. However i found only properties for fore and background. 


How to achieve this?


Thanks and br.


1 Reply

EE Elavazhagan Elangovan Syncfusion Team August 26, 2025 02:29 PM UTC

Hi Franz Gruber-Leitner,

We understand your requirement to modify font properties such as size, weight, and family upon selection in the DataGrid. While the default styling options mainly cover foreground and background colors, this customization can be achieved by defining the desired font styles in XAML and applying them conditionally using a StyleSelector. The StyleSelector allows you to dynamically assign styles based on the selection state of each cell, enabling you to reflect changes in font appearance when performing selection.

Code snippet related to Define font style on AppXaml:

<Application.Resources>

    <local:RowSelectionStyleSelector x:Key="SelectionStyleSelector"/>

    <Style TargetType="syncfusion:GridCell" x:Key="selectedStyle" >

        <Setter Property="FontSize" Value="20"/>

        <Setter Property="FontWeight" Value="Bold"/>

        <Setter Property="FontFamily" Value="Agency FB"/>

    </Style>

</Application.Resources>



Code snippet related to apply styles on selected cell using StyleSelector:

public class RowSelectionStyleSelector : StyleSelector

{

    public override Style SelectStyle(object item, DependencyObject container)

    {

        var data = item as OrderInfo;

        var grid = FindParent<SfDataGrid>(container);

 

        if (data != null && grid != null && grid.SelectedItems.Contains(data))

        {

            return App.Current.Resources["selectedStyle"] as Style;

        }

 

        return base.SelectStyle(item, container);

    }

}



Code snippet related apply styles on DataGrid:

<Grid>

    <syncfusion:SfDataGrid x:Name="sfDataGrid" ItemsSource="{Binding Orders}" CellStyleSelector="{StaticResource SelectionStyleSelector}" />

</Grid>



UG Link: SelectionStyle

Find the sample demo in the attachment.
 

Please let me know if you have any concerns.

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Regards,
Elavazhagan E



Attachment: SfDataGridDemo_352af5be.zip

Loader.
Up arrow icon