Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is no need to create a hidden Window, you can render WPF controls for printing by using a <a href="http://msdn.microsoft.com/en-us/library/system.windows.documents.documentpage.aspx" rel="nofollow">DocumentPage</a>. To print <code>DocumentPage</code>s , you will need to need to extend the <a href="http://msdn.microsoft.com/en-us/library/system.windows.documents.documentpaginator.aspx" rel="nofollow">DocumentPaginator</a> class.</p> <p>The code to implement an a simple <code>DocumentPaginator</code> that will print out any <code>List</code> of <code>UIElements</code> is below.</p> <pre><code>class DocumentPaginatorImpl : DocumentPaginator { private List&lt;UIElement&gt; Pages { get; set; } public DocumentPaginatorImpl(List&lt;UIElement&gt; pages) { Pages = pages; } public override DocumentPage GetPage(int pageNumber) { return new DocumentPage(Pages[pageNumber]); } public override bool IsPageCountValid { get { return true; } } public override int PageCount { get { return Pages.Count; } } public override System.Windows.Size PageSize { get { /* Assume the first page is the size of all the pages, for simplicity. */ if (Pages.Count &gt; 0) { UIElement page = Pages[0]; if (page is Canvas) return new Size(((Canvas)page).Width, ((Canvas)page).Height); // else if ... } return Size.Empty; } set { /* Ignore the PageSize suggestion. */ } } public override IDocumentPaginatorSource Source { get { return null; } } } </code></pre> <p>Finally, to do the printing, you would only need to:</p> <pre><code>dialog.PrintDocument(new DocumentPaginatorImpl(pages), "Print Job Description"); </code></pre>
    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.
    1. VO
      singulars
      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