I have a simple flow document in my resources, FlowDocument1.xaml
:
<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
ColumnWidth="400" FontSize="14" FontFamily="Georgia">
<Paragraph>
Test
</Paragraph>
</FlowDocument>
And I want to show this document in a DocumentViewer
. I searched for a property that takes path but I couldn't find one. And the following throws an exception:
<DocumentViewer x:Name="TestViewer" Document="Resources/FlowDocument1.xaml" />
How can I show FlowDocument1.xaml
in a DocumentViewer
?
First you cannot add a
FlowDocument
to aDocumentViewer
because it only supportsFixedDocument
. You may useFlowDocumentScrollViewer
orFlowDocumentPageViewer
instead.Then you have to set the
Document
property in code: