How to load an XPS document into the DocumentViewer?

Platform: WPF|Category: DocumentViewer

XPS documents can be easily loaded into the documentviewer.

Here’s the code snippet.

[XAML]
          
   <DocumentViewer Name='documentViewer' />
[C#]

   XpsDocument xpsDocument = new XpsDocument('sample.xps', FileAccess.Read);
   documentViewer.Document = xpsDocument;