In WPF, in order to add a FixedPage
to a FixedDocument
in code one needs to:
var page = new FixedPage();
var pageContent = new PageContent();
((IAddChild)pageContent).AddChild(page);
This appears to be the only way, however:
The MSDN documentation explicitly says one shouldn't do this ('This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.'- PageContent.IAddChild.AddChild Method).
It's ugly to have to cast to an explicit interface implementation in order to add the content to
PageContent
.It's not simple to perform the basic operation of
PageContent
.
The documentation doesn't actually explain how to do this and I couldn't find any other information on how to do it. Is there another way? A 'correct' way?