Click here to Skip to main content
14,775,081 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to load a Coded[means, making by C# source code] FlowDocument to DocumentViewer

reportView.Document = null;

Matrix rpt = new Matrix(); // This is my FlowDocument

try
{
    reportView.Document = rpt; //This part always throws an exception
    //Exception: DocumentViewer supports only FixedDocument or             FixedDocumentSequence documents.
}
catch { }


Even though it throw exception this works fine and load the document, if we call it on Page_Load.

"But its not working on a Button_Click()"

I couldn't find any refresh function for DocumentViewer.
Invalidate...() - functions not helping.

I am digging into the reason why the DocumentViewer showing the the FlowDocument while we set at Page_Load() and not at Button_Click().

Have any Idea?
Posted
Updated 21-Jul-11 19:07pm
v2

1 solution

The exception message kind of tells you that you need something to view a flowdocument, not a fixeddocument....maybe use a FlowDocumentScrollViewer, FlowDocumentPageViewer, or FlowDocumentReader?
   
v2
Comments
derinpdavis 21-Jul-11 21:41pm
   
but FlowDocumentPageViewer - (1) doesn't have the print option in-built,
(2) wouldn't have the nice look,
(3) options should be on top [like document viewer]
Mark Salsbery 21-Jul-11 21:43pm
   
FlowDocumentReader?
derinpdavis 21-Jul-11 23:27pm
   
I have tried FlowDocumentPageViewer, FlowDocumentReader, FlowDocumentScrollViewer but I like DocumentViewer

for FlowDocumentReader - IsPrintEnabled property I set to true, still I am not getting print option.
Mark Salsbery 21-Jul-11 23:37pm
   
DocumentViewer is the documented wrong element for flowdocuments but if you like it use it.

As for the print option, the docs state "The default toolbar UI does not include a Print button". IsPrintEnabled enables the routed command, that's it.
derinpdavis 22-Jul-11 0:06am
   
Mark, I am digging into the reason why the DocumentViewer showing the the FlowDocument while we set at Page_Load() and not at Button_Click().
I appreciate your help and time. Thanks
Mark Salsbery 22-Jul-11 1:48am
   
If you Bing/Google search on "DocumentViewer FlowDocument" you'll find many questions asked about that. Apparently at one time DocumentViewer could be used for flowdocuments but in one framework version that went away by design. DocumentViewer may still work partially, but it's now documented for fixed document content.

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