You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
I'm using PrintHelper extension of windows-community-toolkit and printing some data. The problem is when data is large it overlaps the page and i can't find a way to dynamically add a new page and shift data to next page. Is there a way ?
public PrintHelper PrintHelper;
public void StartPrint(Panel container, List<CompanyDetail> PrintSampleItems)
{
try
{
PrintHelper = new PrintHelper(container);
PrintHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;
PrintHelper.OnPrintFailed += PrintHelper_OnPrintFailed;
PrintHelper.OnPreviewPagesCreated += PrintHelperOnOnPreviewPagesCreated;
var pageNumber = 0;
var data = PrintSampleItems;
var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() {Height = GridLength.Auto});
grid.RowDefinitions.Add(new RowDefinition() {Height = new GridLength(1, GridUnitType.Star)});
grid.RowDefinitions.Add(new RowDefinition() {Height = GridLength.Auto});
// Static header
var header = new TextBlock
{
Text = "Departments Print",
Margin = new Thickness(0, 0, 0, 20),
HorizontalAlignment = HorizontalAlignment.Center,
FontSize = 18,
FontWeight = FontWeights.Bold
};
Grid.SetRow(header, 0);
grid.Children.Add(header);
var dataGrid = new CompanyDetailReportTemplateControl
{
HorizontalAlignment = HorizontalAlignment.Center
};
dataGrid.SetValues(PrintSampleItems);
Grid.SetRow(dataGrid, 1);
grid.Children.Add(dataGrid);
// Footer with page number
pageNumber++;
var footer = new TextBlock
{
Text = $"Page [ {pageNumber} ]", Margin = new Thickness(0, 20, 0, 0),
HorizontalAlignment = HorizontalAlignment.Right
};
Grid.SetRow(footer, 2);
grid.Children.Add(footer);
PrintHelper.AddFrameworkElementToPrint(grid);
}
catch
{
}
}
The result looks like this. As can be seen if data is large it is not printed because next page is not added automatically. I can do that be manually looping data and defining exactly how many rows to print on one page and how many on next but that's not what i want cuz if some cell data is large then my logic won't work.
I'm using
PrintHelperextension ofwindows-community-toolkitand printing some data. The problem is when data is large it overlaps the page and i can't find a way to dynamically add a new page and shift data to next page. Is there a way ?The result looks like this. As can be seen if data is large it is not printed because next page is not added automatically. I can do that be manually looping data and defining exactly how many rows to print on one page and how many on next but that's not what i want cuz if some cell data is large then my logic won't work.