wpf 文档查看器和简单文本

wpf documentviewer and simple text

我需要在打印前为用户显示文本并允许打印。 我尝试使用 DocumentViewer,但找不到显示简单文本的示例。只有Word或XPS,但它是overgear解决方案。

有没有办法打印简单的多行文本抛出 DocumentViewer

var printText = @"Multiline text to view and print
Line1 Content
Line2 Content
";

并查看

<DocumentViewer>
    <FixedDocument></FixedDocument>
</DocumentViewer>     

如何进行这项工作?

一个FlowDocument?

<FlowDocumentReader xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <FlowDocument>
    <Paragraph>
      <Bold>Some bold text in the paragraph.</Bold>
      Some text that is not bold.
    </Paragraph>
    <List>
      <ListItem>
        <Paragraph>ListItem 1</Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>ListItem 2</Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>ListItem 3</Paragraph>
      </ListItem>
    </List>
  </FlowDocument>
</FlowDocumentReader>