What's the correct way to add a PageContent/ FixedPage to a FixedDocument in WPF? What's the correct way to add a PageContent/ FixedPage to a FixedDocument in WPF? wpf wpf

What's the correct way to add a PageContent/ FixedPage to a FixedDocument in WPF?


According to MSDN documentation, you simply add a FixedPage object to the PageContent.Child property and then add that to the FixedDocument by calling the FixedDocument.Pages.Add method.

For instance:

public FixedDocument RenderDocument() {    FixedDocument fd = new FixedDocument();    PageContent pc = new PageContent();    FixedPage fp = new FixedPage();    TextBlock tb = new TextBlock();    //add some text to a TextBox object    tb.Text = "This is some test text";    //add the text box to the FixedPage    fp.Children.Add(tb);    //add the FixedPage to the PageContent     pc.Child = fp;    //add the PageContent to the FixedDocument    fd.Pages.Add(pc);    return fd;}