When printing a DataGrid control, it does not show any data. (PrintDialog.PrintVisual)
See original GitHub issueDescribe the bug When printing a DataGrid control, it does not show any data.
To Reproduce Steps to reproduce the behavior:
- Create a new XAML user control (
MyPrintPageView
)
<DataGrid
AutoGenerateColumns="True"
ItemsSource="{Binding OtherMovementsList}"
HorizontalAlignment="Left"/>
- Print the view:
PrintDialog printDialog = new PrintDialog();
var print = new MyPrintPageView();
print.DataContext = new MyViewModel();
printDialog.PrintVisual(print, "Printing bug!");
- 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:
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>
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"/>
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:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jhm-ciberman I close it, if there is a problem, open it again
the latest code seems to be working fine