Hello,
Welcome to Microsoft Q&A!
You could use the PrintHelper class to print the ListView, but it won't automatically page based on the length of the ListView, so you still need to manually paging your data in code-behind. You can divide the long ListViewand calculate the maximum number of ListView-Items that can display on the screen together and then put them into print-pages. For example:
.xaml:
<Page.Resources>
<DataTemplate x:Name="CustomPrintTemplate">
<StackPanel>
<TextBlock
Text="{Binding Description}"
TextWrapping="Wrap"/>
<TextBlock
Text="{Binding SourceUrl}"
TextWrapping="Wrap"/>
</StackPanel>
</DataTemplate>
</Page.Resources>
<StackPanel>
<Button Click="Button_Click">Print</Button>
<Grid x:Name="Container" Opacity="0" />
<ListView Height="600" x:Name="PrintSampleListView" ItemsSource="{x:Bind Lists,Mode=OneWay}" ItemTemplate="{StaticResource CustomPrintTemplate}" />
</StackPanel>
.cs:
private PrintHelper _printHelper;
private async void Button_Click(object sender, RoutedEventArgs e)
{
_printHelper = new PrintHelper(Container);
for (int i = 0; i < Lists.Count; i = i + 4)
{
var grid = new Grid();
// Main content with layout from data template
var listView = new ListView();
listView.ItemTemplate = CustomPrintTemplate;
listView.ItemsSource = Lists.Skip(i).Take(4);
grid.Children.Add(listView);
_printHelper.AddFrameworkElementToPrint(grid);
}
var printHelperOptions = new PrintHelperOptions(false);
printHelperOptions.Orientation = Windows.Graphics.Printing.PrintOrientation.Default;
printHelperOptions.AddDisplayOption(StandardPrintTaskOptions.Orientation);
await _printHelper.ShowPrintUIAsync("print sample", printHelperOptions);
}