How to hide WPF DocumentViewer menu panels?

I currently have a DocumentViewer in a WPF window that displays an XPS file. I created my own Next Page and Previous Page buttons and set the DocumentViewer.Background property to be completely transparent.

All that remains of the DocumentViewer's own controls is the menu bar at the top (displaying zoom settings, printing, etc.) and the Find panel at the bottom. I would really like to remove (or hide) both of these columns, but I cannot figure out how to do this?

In addition, when a document is loaded, by default it has a zoom level that does not display the entire page on the screen, I need to change it to display 1 page at a time (in full); I am sure there is a way to do this, but then again, I have not yet found how to do this.

+6
wpf xps documentviewer xpsdocument
source share
2 answers

To remove a toolbar, you need to modify the DocumentViewer management template.

Start with the template in this link http://msdn.microsoft.com/en-us/library/aa970452.aspx and delete the ToolBar element (and possibly also the ContentControl with x: Name = "PART_FindToolBarHost" below).

About setting up scaling, I don’t have an elegant XAML solution, but you can call the DocumentViewer FitToWidth or FitToHeight methods after loading the document (and on each page, if necessary, you already have your own next / previous page code that can call these methods)

+8
source share

Here is a simple way to "work around" to simply hide those elements that do not require overriding the entire control pattern:

  <DocumentViewer> <DocumentViewer.Resources> <!-- Hides the search box--> <Style TargetType="ContentControl"> <Setter Property="Visibility" Value="Collapsed" /> </Style> <!-- Hides the toolbar --> <Style TargetType="ToolBar"> <Setter Property="Visibility" Value="Collapsed" /> </Style> </DocumentViewer.Resources> </DocumentViewer> 
+20
source share

All Articles