Articles in this section
Category / Section

How to apply Alternating Row style while printing SfDataGrid in WPF ?

2 mins read

SfDataGrid allows you to customize the DataGrid while printing, with the help of custom print manager that is derived class from GridPrintManager of SfDataGrid. Using custom print manager you can customize the row style, row height, column width, header text, etc. Also you can apply alternating row style by overriding the GetPrintGridCell method in the CustomPrintManager class and set the background to PrintGridCell.

The following code example explains you how to create Custom Print Manager Class and override GetPrintGridCell method to apply the alternating row style.


internal class CustomPrintManager : GridPrintManager
private SfDataGrid dataGrid;
public CustomPrintManager(SfDataGrid grid)
: base(grid)
dataGrid = grid;
// Invokes to Get PrintGridCell for the corresponding record and mapping name.
public override ContentControl GetPrintGridCell(object record, string mappingName)
var index = dataGrid.View.Records.IndexOfRecord(record);
//set the background of the PrintGridCell
if (index%2 == 0)
return new PrintGridCell() {Background = new SolidColorBrush(Colors.Bisque)};
return base.GetPrintGridCell(record, mappingName);

You can set the above customized print manager to SfDataGrid.PrintSettings.PrintManagerBase property as illustrated in the following code example.


//set Custom Print Manager as PrintManagerBase
dataGrid.PrintSettings.PrintManagerBase = new CustomPrintManager(dataGrid);

The following screenshot displays the print preview of SfDataGrid with Alternating Row Style.

SfDataGrid with Alternating Row style

Figure 1: Print preview of SfDataGrid with Alternating Row Style


Sample Links:





I hope you enjoyed learning about how to apply Alternating Row style while printing SfDataGrid in WPF.

You can refer to our WPF DataGrid feature tourpage to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF DataGrid example 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?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment