Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I know this had already been answered, but I think this answer is nicer because it doesn't require you to add a DocumentView.</p> <p>If there's a way to reference the resources by the key name and put them in the FixedDocument with XAML, please let me know. I can't seem to find a way to do that, but maybe it's possible.</p> <p>Use:</p> <pre class="lang-cs prettyprint-override"><code>var doc = System.Windows.Application.LoadComponent(new Uri("/FixedDocumentExample.xaml", UriKind.Relative)) as FixedDocument; doc.AddPages(); </code></pre> <p>Extension Method:</p> <pre class="lang-cs prettyprint-override"><code>using System.Collections; using System.Windows.Documents; public static class FixedDocumentExtended { public static void AddPages(this FixedDocument fixedDocument) { var enumerator = fixedDocument.Resources.GetEnumerator(); while (enumerator.MoveNext()) { var pageContent = ((DictionaryEntry)enumerator.Current).Value as PageContent; if (pageContent != null) { fixedDocument.Pages.Add(pageContent); } } } } </code></pre> <p>XAML:</p> <pre class="lang-xml prettyprint-override"><code>&lt;FixedDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;FixedDocument.Resources&gt; &lt;PageContent x:Key="page1"&gt; &lt;FixedPage Width="793.76" Height="1122.56"&gt; &lt;TextBlock Margin="50" Text="Page 1"/&gt; &lt;/FixedPage&gt; &lt;/PageContent&gt; &lt;PageContent x:Key="page2"&gt; &lt;FixedPage Width="793.76" Height="1122.56"&gt; &lt;TextBlock Margin="50" Text="Page 2"/&gt; &lt;/FixedPage&gt; &lt;/PageContent&gt; &lt;/FixedDocument.Resources&gt; &lt;/FixedDocument&gt; </code></pre>
 

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