This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, i have a problem with printing diagrams with MVVM. I've tested your example like this:
In your example you've used the formatter from the diagram, but in MVVM there is no way to get the formatter with the FlowDiagramModel. If i use a another, programmatically build, formatter a XpsSerialization exception is thrown. Is there a way to get the formatter which i have build in xaml? How can i solve this problem? Thank you! Best Regards, Jan |
|
|
Hello Jan The only way to do this is to get the DiagramFormatter from the xaml resource dictionary, or from the Formatter property of the DiagramSurface instance. Indeed this is tricky to do in an MVVM application. The formatter is required for the printing to know what everything should look like, but the formatter is populated with styles and templates so it does not belong in the model. This means the printing operation isn't model friendly either. The printing operation may need to be done inside a user control or in some code-behind that has access to the DiagramSurface. Then the easiest way to trigger the printing operation would probably be by using .Net commands. Hope that helps. -Jason Fauchelle |
|
|
Hi, i now have done it that dirty way, but it still doesn't work. I now set a property in the ViewModel from code-behind, so that i have the right formatter. In the line were the writer.Write(doc.Document); is called, a XpsSerializationException (" "Fixed Document" must contain at least one "FixedPage"") is thrown. It's the same like before. For the Diagram property of the DiagramPrinter i use the FlowDiagramModel, it isn't possible to get the diagram directly with the same method like the formatter, because it is used by datatemplates. Best regards, Jan |
|
|
Hello Jan Using the FlowDiagramModel from your own model will be perfectly fine. I have tried many way to cause this issue but have not been able to reproduce this. One thing to try is getting the latest nightly build. You may have an older version with a bug in it - though I don't remember encountering this issue before. You can get the latest nightly build from here: http://www.mindscapehq.com/products/wpfdiagrams/nightly-builds If you already have this latest version, or if the problem remains, please send me a repro project so that I can debug this and find the solution for you. -Jason Fauchelle |
|