问题描述
此刻,我在显示XPS文件的WPF窗口中有一个DocumentViewer
.我创建了自己的下一页"和上一页"按钮,并将DocumentViewer.Background
属性设置为完全透明.
At the moment I have a DocumentViewer
in a WPF window that displays an XPS file. I have created my own "Next Page" and "Previous Page" buttons and have set the DocumentViewer.Background
property to be completely transparent.
DocumentViewer自己的控件仅剩下顶部的菜单栏(显示缩放设置,打印等),底部的查找"栏.我很想删除(或隐藏)这两个栏,但似乎无法弄清楚!!
All that is left of the DocumentViewer's own controls is the menu bar at the top (displaying zoom settings, print, etc.) and the "Find" bar at the bottom. I would quite like to remove (or hide) both of these bars, but I can't seem to figure out how!?
此外,在加载文档时,默认情况下缩放比例不会在屏幕上显示整个页面,因此我需要将其更改为一次(完全)显示一页.我敢肯定有办法做到这一点,但同样,我还没有找到方法.
Also, when the document is loaded it defaults to a zoom level that doesn't display the entire page on screen, I need to change it to display 1 page at a time (fully); I'm sure there is a way of doing this but again, I haven't found how as yet.
推荐答案
要删除工具栏,必须更改DocumentViewer的控件模板.
To remove the toolbar you have to change the DocumentViewer's control template.
从此链接中的模板开始 http://msdn.microsoft.com/en-us/library/aa970452.aspx 并删除ToolBar元素(以及底部的x:Name ="PART_FindToolBarHost"的ContentControl).
Start with the template in this link http://msdn.microsoft.com/en-us/library/aa970452.aspxand remove the ToolBar element (and maybe also the ContentControl with x:Name="PART_FindToolBarHost" at the bottom).
关于设置缩放比例,我没有一个优雅的XAML解决方案,但是在加载文档后,您可以调用DocumentViewer的FitToWidth或FitToHeight方法(如果需要,每个页面都已经有自己的下一页/上一页可以调用这些方法的代码)
About setting the zoom, I don't have an elegant XAML solution, but you can call the DocumentViewer's FitToWidth or FitToHeight methods after you load the document (and every page if you must, you already have your own next/prev page code that can call those methods)
这篇关于如何隐藏WPF DocumentViewer的菜单栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!