Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,783 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I don't find WPF example. Who can help me? Thanks
You can use DocumentViewer to view control that can host paginated FixedDocument content such as an XpsDocument. I will show you a sample of using DocumentViewer to print pdf:
Here is the cs code:
public MainWindow()
{
InitializeComponent();
LoadDocumentViewer("E:\\WPF case\\0622\\pdf\\temp.xps", docViewer);
}
static XpsDocument xpsPackage = null;
public static void LoadDocumentViewer(string xpsFileName, DocumentViewer viewer)
{
XpsDocument oldXpsPackage = xpsPackage;
xpsPackage = new XpsDocument(xpsFileName, FileAccess.Read, CompressionOption.NotCompressed);
FixedDocumentSequence fixedDocumentSequence = xpsPackage.GetFixedDocumentSequence();
viewer.Document = fixedDocumentSequence as IDocumentPaginatorSource;
if (oldXpsPackage != null)
oldXpsPackage.Close();
xpsPackage.Close();
}
Add a DocumentViewer in the xaml:
<DocumentViewer Name="docViewer"></DocumentViewer>