简体   繁体   中英

How can I separate the navigation of an XpsDocument in a DocumentViewer control from the containing NavigationWindow?

In some WPF XAML, I'm using a DocumentViewer control within my NavigationWindow to display an XPS document (via the XpsDocument class), per the simple instructions here on the MSDN Blogs .

Unfortunately, the navigation within the XPS document (internal hyperlinks) propagate to the journal of the NavigationWindow , rather than being contained within the DocumentViewer control. I'm wondering how I can separate the two, perhaps using a Frame that points to some XAML that contains the DocumentViewer , per the topic pictured here on MSDN . But I'm really new to this whole idea. Does anyone have or know of any code they could point me toward?

Thanks in advance!

I figured this out by piecing together documentation and information from MSDN. Some code fragments below in case it helps anyone else.

Within the UserControl navigated to by the NavigationWindow I placed (among other window content) the Frame , as shown

<Frame Name="xpsFrame" NavigationUIVisibility="Hidden" JournalOwnership="OwnsJournal" />

and in the code behind I called

XpsDocument xpsDoc = new XpsDocument(pathToDocument, System.IO.FileAccess.Read);
manualFrame.Navigate(xpsDoc.GetFixedDocumentSequence());

This allowed the display of the XPS document within a specified portion of the NavigationWindow while keeping the navigation within the XPS document (in the Frame ) separate from the main window navigation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM