I've been searching the web for over 2 days now for a good and easy to use something to print reports from a WPF application.
I've been trying to use the DocumentViewer
but it's a pain to add Controls
to it and style them. Is it me or can this only be done in code behind and how can a grid over multiple pages dynamically be generated?
Second I found the control FlowDocumentReader
. This looks like an interesting thing since you can add Tables
which are much easier to style and I was able to do this in xaml. Unfortunately, I have no clue how to print from it. I tried to edit the template of the reader but without success.
Last I found this post (What's the best approach to printing/reporting from WPF?) but it's dated to 2008 so I'm not sure if the information is still accurate.
My conclusion is that it is pretty hard to get a nice looking report printed from WPF without writing lots of code behind or editing templates which (by me) fail to do what I want.
So my question is, is there any good approach to my problem? I'm really bothered that I lost this much time for something that I thought was so trivial to do.
I was wonder, what about this guy's approach: https://stackoverflow.com/questions/17647939/how-do-we-handle-different-printing-needs-by-using-fixeddocument?rq=1?