2015-05-23 23 views
0

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

有什么办法来打印简单的多行文本抛出的DocumentViewer

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

,并查看

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

如何使这项工作?

+0

这应该启动你在正确的路径http://stackoverflow.com/a/10258079/3225 – kenny

回答

0

A 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> 
+0

谢谢,它的工作原理。 – Json76

+0

@ Json76然后你可以给出的是一个复选标记,表明它是一个答案 – Paparazzi

+0

一个问题 - 它没有显示DocumentViewer中的阅读器工具栏(其中放大按钮和其他)的打印按钮。尝试设置IsPrintEnabled = true没有帮助。这不是什么大问题,但是在布局中我需要自定义按钮的预留位置 – Json76