2010-04-24 97 views

回答

3

从SAP支持站点 http://forums.sdn.sap.com/message.jspa?messageID=8995372

//Using the ReportDocument SDK 
this._report = new ReportDocument(); 
this._report.Load(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\CrystalReportWpfApplication1\CrystalReportWpfApplication1\CrystalReport1.rpt"); 
this.reportViewer.ViewerCore.ReportSource = this._report; 
1

这可能是很晚的答案,但可能会帮助别人谁正在寻找一个类似的问题。 如果要绑定ReportSource,则需要将CrystalReportViewer控件包含在UserControl的WindowsFormsHost中,并声明类型为string的依赖项属性。您需要从这里设置ReportSource。您不能直接将其从本地控件与XAML绑定。

1

我有同样的问题,但就像最后一篇文章,虽然它可能有助于他人。

WPF的CrystalReportViewer有一个名为“Content”的属性。这个Content属性实际上是一个StackPanel,带有3个子节点,第三个是这个新元素“ViewerCore”,它填充了DockPanel(LastChildFill)上的所有可用空间。

ReportSource属性是在这个ViewerCore,所以访问此ViewerCore(只读)属性,你需要做到以下几点:

添加引用SAPBusinessObjects.WPF.Viewer

添加using语句using SAPBusinessObjects.WPF.Viewer;

,然后设定报表使用

ViewerCore view = crReportViewer.ViewerCore; view.ReportSource = cryRpt;

源10

HTH Noelle