强制数据绑定 - 在进行打印时丢失在wpf数据绑定的沟槽中 [英] Force Databinding - Lost in the trenches of wpf databinding when doing printing

查看:67
本文介绍了强制数据绑定 - 在进行打印时丢失在wpf数据绑定的沟槽中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。



我正在尝试生成一个由绑定到viewmodel的视图制作的flowdocument。

我之前做过这个,但后来我必须手动将视图绑定到viewmodel。当时它不是问题,因为viewmodel非常小。但这一次......

绑定工作真的会有所帮助。问题似乎是我没有显示我的usercontrol,而是使用它来生成一个flowdocument。



以下是一些代码:

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:

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)







有趣的是绑定确实发生了,但是值没有出现在flowdocument上。 。

(我知道这是因为我试图绑定到一个不存在的属性然后我在输出窗口中收到一个错误,但现在我没有得到任何错误,如果我在一个断点中绑定财产,亲perty受到了打击。)



我试图在视图上调用UpdateLayout,但这没有帮助。



IReportView是一个简单的界面,我放在视图上,可以传递给这个函数。 (用于分页)

视图是UserControl。



任何帮助表示感谢。




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.

推荐答案

Hi WiiMaxx



如果我没记错的话,我最终将模型Handbinding到了flowdocument。真的很糟糕,但那是我找到的唯一解决方案......
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...


这篇关于强制数据绑定 - 在进行打印时丢失在wpf数据绑定的沟槽中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆