更改 WPF DocumentViewer 查看模式

发布于 2024-12-17 15:33:22 字数 355 浏览 2 评论 0原文

您好,我遇到了一个问题,当我添加 时,我会得到一个工具栏,允许我更改 XPS 文档的查看模式,例如这里: 在此处输入图像描述

但是我如何以编程方式执行此操作? 我找不到任何可以执行此操作的属性,MSDN 和 Google 也没有提及此功能。 然后我发现 FlowDocumentReader 控件具有 ViewingMode 属性,但它无法显示 XPS 文档。我不敢相信这是不可能做到的,我的意思是该功能默认可用,我只想以编程方式更改它......

Hello I've got the problem that when I just add a <DocumentViewer x:Name="docViewer" /> I get a toolbar what allow me to change the viewing mode of the XPS document like here:
enter image description here

But how can I do this programmatically?
I cant find any property that do this and the MSDN and Google say nothing about this feature.
Then I found the FlowDocumentReader control what have a ViewingMode property, however it can't display a XPS document. I can't believe that it is not possible to do this, I mean that function is available by default, I just want to change it programmatically...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小忆控 2024-12-24 15:33:22

DocumentViewer 没有公开任何属性来更改 ViewMode。但如果您想以编程方式更改 ViewMode,则可以执行 DocumentViewer 公开的命令,如下所示 -

  • DocumentViewer.FitToWidthCommand
  • DocumentViewer.FitToHeightCommand
  • DocumentViewer.FitToMaxPagesAcrossCommand

您可以将这些命令绑定到自定义按钮,或者以编程方式更改 ViewMode。假设您有一个名为 documentViewerDocumentViewer,您可以像这样在此实例上调用这些方法 -

  • documentViewer.FitToWidth()
  • documentViewer.FitToHeight()
  • documentViewer.FitToMaxPagesAcross()

DocuementViewer didn't exposed any property to change the ViewMode. But in case you want to change the ViewMode programmatically, you can execute the commands exposed by DocumentViewer which are as -

  • DocumentViewer.FitToWidthCommand
  • DocumentViewer.FitToHeightCommand
  • DocumentViewer.FitToMaxPagesAcrossCommand

You can bind these commands to your custom button or programmatically you can change the ViewMode. Suppose you have a DocuementViewer named documentViewer, you can call these methods on this instance like this -

  • documentViewer.FitToWidth()
  • documentViewer.FitToHeight()
  • documentViewer.FitToMaxPagesAcross()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文