WPF与MVVM:如何显示文档XPS [英] WPF with MVVM : How to show a document XPS

查看:79
本文介绍了WPF与MVVM:如何显示文档XPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各位大家好!



我正在寻找一个解释如何在我使用时向WPF显示XPS文档文件

的示例MVVM模式。



我发现如何在没有MVVM的情况下做到这一点......但MVVM没有任何作用。

我上周启动了MVVM。 ..我正在学习WPF。

微软没有例子。



必须简单但我无法弄明白。



谢谢。

:)



注意:我使用C#(c sharp) )。

Hello everybody !

I am looking for an example that explain how to SHOW a XPS document file
into WPF when I use MVVM pattern.

I found how to do it without MVVM ... but nothing work with MVVM.
I start MVVM last week ... I am learning WPF.
Microsoft does not have an example.

Must be easy but I cannot figure out.

Thank you.
:)

Note: I use C# (c sharp).

推荐答案

我自己找到了。



MVVM:



在视图cs文件(myfile.xaml.cs)中,我将以下内容放在构造函数中:



XpsDocument xpsDocument = new XpsDocument(@c:\ MyDocument.xps,FileAccess.Read);

documentviewWord.Document = xpsDocument.GetFixedDocumentSequence();





在视图文件(myfile.xaml)中,我输入以下o bject我想要的地方:



< documentviewer name =documentviewWordverticalalignment =Tophorizo​​ntalalignment =Centerheight =500>





因此documentviewWord对象与我打开的XPS文件绑定。



:)



注意:你需要使用ReachFramework作为参考。
I found it myself.

With MVVM:

In the view cs file ( myfile.xaml.cs ), I put the following in the constructor:

XpsDocument xpsDocument = new XpsDocument(@"c:\MyDocument.xps", FileAccess.Read);
documentviewWord.Document = xpsDocument.GetFixedDocumentSequence();


In the view file ( myfile.xaml ), I put the following object where I want it:

<documentviewer name="documentviewWord" verticalalignment="Top" horizontalalignment="Center" height="500">


So the documentviewWord object is BINDED to the XPS file I have open.

:)

Note: You need to use the ReachFramework as a Reference.


请看我过去的答案:

XPS文档查看器Intersoft ClientUI中的示例 [ ^ ],

XML Paper Specification(XPS) [ ^ ]。



我自己测试过,它有效。



-SA
Please see my past answers:
The XPS Document Viewer Sample In Intersoft ClientUI[^],
XML Paper Specification(XPS)[^].

I tested it myself, it works.

—SA


这篇关于WPF与MVVM:如何显示文档XPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆