Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

I'm trying to generate a flowdocument that is made from a view bound to a viewmodel.
I have done this earlier, but then I had to bind the view to the viewmodel by hand. At the time it was not a problem, because the viewmodel was really small. But this time...
Binding that works would really help. The problem seems to be that I do not show my usercontrol, but rather use it to generate a flowdocument.

Here is some code:
VB
Dim ireport As ViewModel.Reports.IReport = TryCast(reportvm, ViewModel.Reports.IReport)
Dim ReportDocument As New FlowDocument()
ReportDocument.ColumnWidth = 1122.7086 'standard A4
For i = 0 To Math.Ceiling(ireport.NrOfItems / ireport.ItemsOnPage) - 1
    Dim inlinecontainer As New InlineUIContainer
    Dim ReportView As View.Reports.IReportView = repviewgenerator()
    ReportView.DataContext = reportvm
    ReportView.FixTable(i + 1)
    inlinecontainer.Child = ReportView
    RepportDocument.Blocks.Add(New Paragraph(inlinecontainer))
    ireport.PageNr += 1
Next
Dim dps As IDocumentPaginatorSource = ReportDocument
Handelse.Utils.PrintHelper.CreateDocumentPackage(dps)



The funny thing is that binding does occur, but the value does not show up on the flowdocument...
( I know this because I have tried to bind to a non existing property and then I received an error in the output window, but now I get no error, and if I put a breakpoint in a bound property, the property is getting hit.)

I have tried to call UpdateLayout on the view, but that does not help.

IReportView is a simple interface that I put on views that can be passed on to this function. (for paging)
The view is a UserControl.

Any help appreciated.
Posted
Comments
WiiMaxx 9-Jul-13 3:27am    
i have the same problem with one difference in my case only the binding for my first page get lost with no errors so what i want to know did you find a solution to fix your problem so maybe i can adapt it in my c# code

1 solution

Hi WiiMaxx

If I remember correctly I ended up 'Handbinding' the model to the flowdocument. Really sucky, but that was the only solution I found...
 
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