Note that there are some explanatory texts on larger screens.

plurals
  1. POPrinting Dynamic Usercontrol via document paginator in WPF : Datagrid is printed empty
    primarykey
    data
    text
    <p>I am trying to print a wpf document. I am using documentpaginator for pagination and a user control to create actual visual to print. My user control has few textboxes and a datagrid binded to data objects which are passed to the user control at runtime.</p> <p>Now the code works great when printing to an XPS document but when it prints to a physical printer, my datagrid is printed empty though other textboxes are printing perfectly. </p> <p>Below is the code for paginator class GetPage Method :</p> <pre><code> SaleOrderPage page = new SaleOrderPage(order, pageNumber, controlSize); page.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); page.Arrange(new Rect(new Point(0, 0), PageSize)); page.InitPrint(); page.UpdateLayout(); return new DocumentPage(page); </code></pre> <p>InitPrint method is initializing my datagrid and binding it to the datasource. Here is the code for InitPrint method.</p> <pre><code> public void InitPrint() { var sales = ctx.SalesOrders.Where(so =&gt; so.Id.Equals(order.Id)).First().Sales.Skip(pageNumber * PageRows).Take(PageRows); var printData = sales.Select(x =&gt; new { Particulars = string.Format("{0} - {1}", x.Item.Brand.Name, x.Item.Shade.Name), Quantity = string.Format("{0} {1}", x.Quantity, x.Item.Brand.Unit.Symbol) }).ToList(); dgSales.ItemsSource = printData; dgSalesCopy.ItemsSource = printData; } </code></pre> <p>I believe I am missing some step when printing to actual printer because it works as expected to an XPS printer but not to a physical printer.</p> <p>Thanks for reading question, </p> <p>Naveen</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload