Skip to content

SyncfusionExamples/how-to-apply-rowstyle-in-maui-datagrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

How to Apply RowStyle in MAUI DataGrid

In.NET MAUI DataGrid (SfDataGrid) allows you to apply style for the DataGridCells by using the DataGridColumn.CellStyle property.

To apply RowStyle for a particular row/rows, you need to apply the same CellStyle for all the DataGridColumns in the row.

XAML

<syncfusion:SfDataGrid x:Name="dataGrid"
                           AutoGenerateColumnsMode="None"
                           ColumnWidthMode="Auto"
                     ItemsSource="{Binding Info}">

        <syncfusion:SfDataGrid.Columns>
            <syncfusion:DataGridTextColumn MappingName="ID">
                <syncfusion:DataGridTextColumn.CellStyle>
                    <Style TargetType="syncfusion:DataGridCell">                        
                        <Setter Property="Background" 
                    Value="{Binding ID, Converter={StaticResource colorConverter}}" />
                    </Style>
                </syncfusion:DataGridTextColumn.CellStyle>
            </syncfusion:DataGridTextColumn>

            <syncfusion:DataGridTextColumn MappingName="Name">
                <syncfusion:DataGridTextColumn.CellStyle>
                    <Style TargetType="syncfusion:DataGridCell">
                        <Setter Property="Background" 
                    Value="{Binding ID, Converter={StaticResource colorConverter}}" />
                    </Style>
                </syncfusion:DataGridTextColumn.CellStyle>
            </syncfusion:DataGridTextColumn>

            <syncfusion:DataGridTextColumn MappingName="Percentage">
                <syncfusion:DataGridTextColumn.CellStyle>
                    <Style TargetType="syncfusion:DataGridCell">
                        <Setter Property="Background" 
                    Value="{Binding ID, Converter={StaticResource colorConverter}}" />
                    </Style>
                </syncfusion:DataGridTextColumn.CellStyle>
            </syncfusion:DataGridTextColumn>

            <syncfusion:DataGridTextColumn MappingName="Result">
                <syncfusion:DataGridTextColumn.CellStyle>
                    <Style TargetType="syncfusion:DataGridCell">
                        <Setter Property="Background" 
                    Value="{Binding ID, Converter={StaticResource colorConverter}}" />
                    </Style>
                </syncfusion:DataGridTextColumn.CellStyle>
            </syncfusion:DataGridTextColumn>
        </syncfusion:SfDataGrid.Columns>
    </syncfusion:SfDataGrid>

C#

Converter

 public class Converter : IValueConverter
{
    object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo info)
    {
        int _value = (int)value;
        if (_value % 2 == 0)
            return Colors.Yellow;
        return Colors.Transparent;
    }
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

RowStyleAppliedInDataGrid

Conclusion

I hope you enjoyed learning about how to apply RowStyle 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!

About

how to apply rowstyle in maui datagrid

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages