How to highlight row using VisualStateManager in .NET MAUI DataGrid?
We can utilize the VisualStateManager to highlight a row when it is hovered over in the .NET MAUI DataGrid.
XAML
We can set the visual state in the resources section of the content page. Below is the code for setting the VisualStateManager within a style that targets the DataGridRow.
<ContentPage.Resources>
<Style TargetType="syncfusion:DataGridRow">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="Background" Value="Transparent" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Property="Background" Value= "#ccd5ae" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ContentPage.Resources>
Output
Download the complete sample from GitHub.
Conclusion
I hope you enjoyed learning how to highlight a row when hovered using VisualStateManager in .NET MAUI DataGrid.
You can refer to our .NET MAUI DataGrid feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI DataGrid documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI DataGrid and other .NET MAUI components.
Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!