Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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).
Posted
Updated 20-Mar-13 15:24pm
v2
Comments
[no name] 20-Mar-13 21:30pm    
"I found how to do it without MVVM", okay.... that makes no sense. If you can do it without MVVM what is it specifically is it that prevents you from doing it with MVVM? "but nothing work with MVVM" is not a helpful description of a problem.

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.
 
Share this answer
 
v2
Please see my past answers:
The XPS Document Viewer Sample In Intersoft ClientUI[^],
XML Paper Specification(XPS)[^].

I tested it myself, it works.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900