Articles in this section
Category / Section

How to change the grid line color in WPF DataGrid?

1 min read

The SfDataGrid provides an option to customize the Grid line color. By default, the grid line color is shown in a Gray color. But, you can customize the grid line color by customizing style for the Cells in the SfDataGrid (GridCell, GridHeaderCell, GridCaptionSummaryCell, GridTableSummaryCell, GridHeaderIndentCell, GridIndentCell, GridStackedHeaderCellControl, GridGroupSummaryCell).

 In each cell the Grid lines are drawn at Right and Bottom position only. Each cells Grid line color is based on the BorderBrush property of the Cell.

Refer to the following code example where the BorderBrush property is changed to customize the line color.

XAML

<!--  changes the grid line color for GridCell -->
<Style TargetType="syncfusion:GridCell">
<Setter Property="BorderBrush" Value="Green" />
</Style>
<!--  changes the grid line color for GridHeaderCell -->
<Style TargetType="syncfusion:GridHeaderCellControl">
<Setter Property="BorderBrush" Value="Red" />
</Style>
<!--  changes the grid line color for GridCaptionSummaryCell -->
 <Style TargetType="syncfusion:GridCaptionSummaryCell">
 <Setter Property="BorderBrush" Value="Red"/>
 </Style>        
 <!--  changes the grid line color for SfDataGrid -->
 <Style TargetType="syncfusion:SfDataGrid">
 <Setter Property="BorderBrush" Value="Violet"/>
 </Style>        
<!--  changes the grid line color for GroupDropArea -->
<Style TargetType="syncfusion:GroupDropArea">
<Setter Property="BorderBrush" Value="Violet"/>
</Style>
<!--  changes the grid line color for GridIndentCell -->
<Style TargetType="syncfusion:GridIndentCell">
<Setter Property="BorderBrush" Value="Red"/>
</Style>

Refer to the screenshot where the SfDataGrid is loaded with customized grid line color.

C:\Users\jayapradha\Desktop\Gridlines\grid line color.PNG

Refer to the following screenshot with the customized gridline color while grouping.

Graphical user interface, application, table

 

Sample Links:

WPF

WRT

UWP

Conclusion

I hope you enjoyed learning about how to change the grid line color in WPF DataGrid.

You can refer to our WPF Grid feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF Grid documentation to understand how to create and manipulate data.

For current customers, you can check out our 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 other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied