question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When printing a DataGrid control, it does not show any data. (PrintDialog.PrintVisual)

See original GitHub issue

Describe the bug When printing a DataGrid control, it does not show any data.

To Reproduce Steps to reproduce the behavior:

  1. Create a new XAML user control (MyPrintPageView)
<DataGrid 
    AutoGenerateColumns="True" 
    ItemsSource="{Binding OtherMovementsList}" 
    HorizontalAlignment="Left"/>
  1. Print the view:
PrintDialog printDialog = new PrintDialog();

var print = new MyPrintPageView();
print.DataContext = new MyViewModel();
printDialog.PrintVisual(print, "Printing bug!");
  1. Execute the app and save the printing as PDF (or print it with an actual printer if you have ink to spare). The DataGrid will show but the content will be empty:

image

Below is a ListView with a GridView as view for comparison: (it renders correctly)

<ListView
    ItemsSource="{Binding OtherMovementsList}" 
    HorizontalAlignment="Left">
    <ListView.View>
        <GridView>
            <!-- columns here -->
        </GridView>
    </ListView.View>
</ListView>

image

Also, here is a comparison for a regular DataGrid with his style set to null. (Style={x:Null}). It renders correctly, but it looks awful.

<DataGrid 
    AutoGenerateColumns="True" 
    Style="{x:Null}"
    ItemsSource="{Binding OtherMovementsList}" 
    HorizontalAlignment="Left"/>

image

Expected behavior The data grid should render it’s content

Environment (please complete the following information):

  • .net: Net 5
  • IDE VS2019
  • Version: HandyControls v3.3.7

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ghost1372commented, Dec 4, 2021

@jhm-ciberman I close it, if there is a problem, open it again

1reaction
NaBiancommented, Dec 3, 2021

the latest code seems to be working fine

Read more comments on GitHub >

github_iconTop Results From Across the Web

Print Datagrid records in WPF
I need only records. PrintDialog printDlg = new PrintDialog(); printDlg.PrintVisual(grid1, "Grid Printing.");.
Read more >
How to print complete data grid values into pdf using ...
First off, don't print a DataGridView: that's a control, not the data it contains, and it only usually displays a small subset of...
Read more >
problem in printing a daagridview in wpf
See more: ... i am using printdialog control to print the datagrid here is my code ... PrintVisual(billsearchgrid ,"print" ); //error line }...
Read more >
Print a DataGrid in WPF
The following code snippet in creates a PrintDialog object and calls its PrintVisual method by passing a UserControl to print the UserControl.
Read more >
PrintDialog component overview - Windows Forms .NET
Use the PrintDialog.ShowDialog method to display the dialog at run time. This component has properties that relate to either a single print ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found